The Mossmouth Forums

Games => Source => Topic started by: Kegluneq on January 01, 2010, 11:00:46 PM



Title: Game Maker Help Thread!
Post by: Kegluneq on January 01, 2010, 11:00:46 PM
Let us mod developers use this thread as a place for us all to ask for and receive help, and for non-pro-owners to ask pro-owners to compile their code for them!

Also, this prevents there from being a whole new thread for just one question.

Please, let's try and keep this thread on-topic and keep away from any de-railing.
While uber noob questions (you know what I mean) are generally frowned upon, beginner questions regarding the Game Maker Language or using Game Maker itself are accepted.

Tutorials are also recommended and greatly appreciated.

To keep the easily answered questions to a minimum and the intellectual ones to a maximum, please consult Game Maker's help file first, as many questions can be answered there.

Disclaimer: I, the thread creator, Mossmouth, Derek Yu, Olmec, Kali or any affiliations with the previous are not responsible for any unanswered queries. However, you are responsible for appropriate, non-flammatory (http://en.wikipedia.org/wiki/Flaming_(Internet)) behavior, and will be "for shamed" should you neglect your responsibilities.

Making a timer (http://mossmouth.com/forums/index.php?topic=586.msg12169#msg12169)
Adding items to crates (http://mossmouth.com/forums/index.php?topic=586.msg12222#msg12222) and more crate madness! (http://mossmouth.com/forums/index.php?topic=586.msg18960#msg18960)
Spawning items from jars (testing/debug purposes) (http://mossmouth.com/forums/index.php?topic=586.msg13422#msg13422)
Stop an item from being on sale when spawned, and more test/debug code (http://mossmouth.com/forums/index.php?topic=586.msg13439#msg13439)
How the idol works (http://mossmouth.com/forums/index.php?topic=586.msg14380#msg14380)
Editing rooms (http://mossmouth.com/forums/index.php?topic=628.0)
Add stuff to the HUD (http://mossmouth.com/forums/index.php?topic=586.msg15481#msg15481)
Where the item pickup code is (http://mossmouth.com/forums/index.php?topic=586.msg17048#msg17048)
Turning an object into a light source (http://mossmouth.com/forums/index.php?topic=586.msg17312#msg17312)
Quick variable check (test/debug purposes) (http://mossmouth.com/forums/index.php?topic=586.msg17863#msg17863)
Add a new action button (http://mossmouth.com/forums/index.php?topic=586.msg17981#msg17981)
Where the input code is (http://mossmouth.com/forums/index.php?topic=586.msg18451#msg18451)
Where item action code is (http://mossmouth.com/forums/index.php?topic=586.msg18601#msg18601)
Add new stuff to shops (http://mossmouth.com/forums/index.php?topic=586.135)


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on January 01, 2010, 11:28:44 PM
Oh good! I was going to ask a question, but this thread got made first!

having problems making a fireball for big bads to shoot. I am not sure where to put the code for spelunker to get hurt, I can make him get hurt just fine, but to react (as if a bullet had hit him) is out of my grasp. I tried stealing the bullet code, but it was for not.


Title: Re: Game Maker Help Thread!
Post by: Kegluneq on January 01, 2010, 11:33:56 PM
Seems to be in [Objects : oPlayer1 : Step : The 1st code action under Hurt]


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on January 01, 2010, 11:46:13 PM
Quote
{
    obj = instance_nearest(x, y, oFireAttack);
    if (obj)
    {
        if (global.plife > 0)
        {
            global.plife -= 1;
            if (global.plife <= 0 and isRealLevel()) global.enemyDeaths[16] += 1;
        }
        if (obj.x < x) xVel = 3;
        else xVel = -3;
        yVel = -5;
       
        scrCreateBlood(x, y, 3);
        playSound(global.sndHurt);
        stunned = true;
        stunTimer = 20;
    }
}
Clearly spelunker is so manly fire just flys threw him.


Title: Re: Game Maker Help Thread!
Post by: Kegluneq on January 01, 2010, 11:52:38 PM
This is the code for the arrow, let's try and break it down

//identify the arrow? Not sure. Maybe this is where the trouble comes from.
obj = instance_nearest(x, y, oArrow);
//Arrows are only dangerous when going faster than 3, and I think your fireballs are never going to be safe, so this line is not needed
    if (obj and abs(obj.xVel) > 3 and not obj.safe)
    {
//If your still alive...
        if (global.plife > 0)
        {
//...then take life away!
            global.plife -= 2;
//If your dead, then rack up a kill for the arrow! (In the detailed stats)
            if (global.plife <= 0 and isRealLevel()) global.miscDeaths[6] += 1;
        }
//Conservation of momentum. Getting hit by the arrow makes you fly as fast the arrow. (actually that's not entirely conservation of momentum but whatever)
        xVel = obj.xVel;
        yVel = -4;
//make blood
        scrCreateBlood(x, y, 3);
//remove the arrow
        with obj
        {
            instance_destroy();
        }
//PAIN!!
        playSound(global.sndHurt);
        stunned = true;
        stunTimer = 20;
    }


Doesn't your code move Mr. Spelunker around? Is that intentional?


Title: Re: Game Maker Help Thread!
Post by: Delver on January 03, 2010, 08:23:36 AM
Can't figure out a way to make my Poison potion work slowly over multipliable lvl  ???

I think of something like:

if global.poison = true
{global.poisontime = global.time}

if (global.time = global.poisontime + 30)
{global.plife -= 1}

if (global.time = global.poisontime + 60)
{global.plife -= 1}

But a can't get it to work, anyone knows where the Time: XX.XX comes from in the pause screen?
 

 


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on January 03, 2010, 01:05:08 PM
Thanks I figured it out! my fireball went slower then 3 and I didn't see that. now it should Does work just fine!

Delver
Have a global variable be added to slowly via timer?


Title: Re: Game Maker Help Thread!
Post by: Kegluneq on January 03, 2010, 04:27:32 PM
Oh I see what's wrong with the poison code. Maybe.

Either your missing parentheses around the first if global.poison = true,

OR

I'm assuming that the whole thing is in the step event?
If so, then it's doing this:

Oh, I'm poisoned. Well let's see, I got poisoned now, so the time I got poisoned is now.
Since the time I got poisoned is now, I guess it's not time for me to get hurt yet.

Next frame:
Oh, I'm poisoned. Well let's see, I got poisoned now, so the time I got poisoned is now.
Since the time I got poisoned is (always and forever will be) now, I guess it's not time for me to get hurt yet.

And this happens EVERY frame.

Instead, use:
if (global.poison and global.time%30000=0)
{global.plife -= 1}

That's every 30 seconds, but not every 30 seconds from the point you get poisoned, it's every 30 seconds from 0 seconds.
So instead:

if (global.poison and not global.checkPoison)
{global.poisontime = global.time; global.checkPoison = true;}

if (global.poison and (global.time-global.poisontime)%30000=0)
{global.plife -= 1}


Make sure to set global.checkPoison to false wherever it is your creating it (and that wherever is definitely NOT in any step events).


Title: Re: Game Maker Help Thread!
Post by: Darkness3313 on January 03, 2010, 05:50:14 PM
Suddenly Keg knows everything about anything ever.

Anyway, I've tried adding the Basketball item to a mod I'm working on, and I can't test it. So my question is, in the ScrGenerateitem
Will this code work?
   else if (rand(1,60) == 1) obj = instance_create(argument0, argument1, oBasketball);


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on January 03, 2010, 05:51:07 PM
Suddenly Keg knows everything about anything ever.

Anyway, I've tried adding the Basketball item to a mod I'm working on, and I can't test it. So my question is, in the ScrGenerateitem
Will this code work?
   else if (rand(1,60) == 1) obj = instance_create(argument0, argument1, oBasketball);
It should? What happens?


Title: Re: Game Maker Help Thread!
Post by: Darkness3313 on January 03, 2010, 05:53:43 PM
A Level may Generate a Basketball, I'm not sure but it will be in a Crate. That's so its easier to test in the Level create as you can make a ton of crates until a Basketball appears. but like I said. I can't test it.


Title: Re: Game Maker Help Thread!
Post by: Sudonimus on January 03, 2010, 05:55:15 PM
What does the basketball do?


Title: Re: Game Maker Help Thread!
Post by: Darkness3313 on January 03, 2010, 05:56:26 PM
I actually don't know, but Derek had it made in the Source, I just added it to the game. I do know it can Dribble though.


Title: Re: Game Maker Help Thread!
Post by: Sudonimus on January 03, 2010, 05:57:22 PM
Like by throwing it
or jumping on it?


Title: Re: Game Maker Help Thread!
Post by: Kegluneq on January 03, 2010, 06:19:11 PM
The code you made should make there a chance to have a basketball pop out of a crate. I don't see any reason why it wouldn't work.

Upon testing the basketball out with the debugger (since I have Pro I get GM's actual debugger), I have found that the basketball is the most fun I've ever had throwing stuff around.

I mean, it's bouncy! What's not to love about that?


Title: Re: Game Maker Help Thread!
Post by: Darkness3313 on January 03, 2010, 06:24:36 PM
Since you have pro, could you test it for me?(The code) I plan on using the Basketball in a mod I will be working on. And it would be nice to be Confident in knowing that the coding I'm using will work when the time for its first release comes around.(Thats when a Thread will be made)


Title: Re: Game Maker Help Thread!
Post by: Delver on January 03, 2010, 06:24:59 PM
Oh I see what's wrong with the poison code. Maybe.

Either your missing parentheses around the first if global.poison = true,

OR

I'm assuming that the whole thing is in the step event?
If so, then it's doing this:

Oh, I'm poisoned. Well let's see, I got poisoned now, so the time I got poisoned is now.
Since the time I got poisoned is now, I guess it's not time for me to get hurt yet.

Next frame:
Oh, I'm poisoned. Well let's see, I got poisoned now, so the time I got poisoned is now.
Since the time I got poisoned is (always and forever will be) now, I guess it's not time for me to get hurt yet.

And this happens EVERY frame.

Instead, use:
if (global.poison and global.time%30000=0)
{global.plife -= 1}

That's every 30 seconds, but not every 30 seconds from the point you get poisoned, it's every 30 seconds from 0 seconds.
So instead:

if (global.poison and not global.checkPoison)
{global.poisontime = global.time; global.checkPoison = true;}

if (global.poison and (global.time-global.poisontime)%30000=0)
{global.plife -= 1}


Make sure to set global.checkPoison to false wherever it is your creating it (and that wherever is definitely NOT in any step events).

thanks... got me on the right track ^^

if anyone needs to make a global timer, here's a pretty nice way (step event for oPoison):

y = oPlayer1.y;
x = oPlayer1.x;

if (global.poison and not global.checkPoison)
{global.poisontime = global.time; global.checkPoison = true;}

if (global.poison and (global.time-(global.poisontime+3000)>0))
{global.poisoncounter += 1;
global.checkPoison = false;
}

if global.poisoncounter = 10
{obj = instance_create(oPlayer1.x, oPlayer1.y, oBlackHeart);
global.plife -= 1;
global.poisonend += 1}

if global.poisoncounter >= 10
{global.poisoncounter = 0}

if global.poisonend = 4
{global.poison = false
instance_destroy()}

For some reason the timer will only work at intervals divided by 3.

if you are using an object make sure it follows the spelunker, otherwise it wouldn't work when in the frozen zone  ;D  


Title: Re: Game Maker Help Thread!
Post by: Kegluneq on January 03, 2010, 06:47:10 PM
Not bad!
A little more roundabout then what I would of done, but pretty good nonetheless.


Title: Re: Game Maker Help Thread!
Post by: Sudonimus on January 03, 2010, 07:01:30 PM
Could any of these codes be used in the Debugger?


Title: Re: Game Maker Help Thread!
Post by: Kegluneq on January 03, 2010, 07:13:46 PM
Technically, but it won't do anything except cause errors.

EDIT:
Hey Darkness I tested the code. It's put in the wrong spot.
Instead, put
else if (rand(1,60) == 1) obj = instance_create(chest.x, chest.y, oBasketball);
in oPlayer1 : step : Action
Scroll down a little and you'll see a
//crate
comment
that's where you put it.


Title: Re: Game Maker Help Thread!
Post by: Darkness3313 on January 03, 2010, 08:22:08 PM
Technically, but it won't do anything except cause errors.

EDIT:
Hey Darkness I tested the code. It's put in the wrong spot.
Instead, put
else if (rand(1,60) == 1) obj = instance_create(chest.x, chest.y, oBasketball);
in oPlayer1 : step : Action
Scroll down a little and you'll see a
//crate
comment
that's where you put it.

Thanks, still in the ScrGenerateitem right?


Title: Re: Game Maker Help Thread!
Post by: Kegluneq on January 03, 2010, 08:41:53 PM
Technically, but it won't do anything except cause errors.

EDIT:
Hey Darkness I tested the code. It's put in the wrong spot.
Instead, put
else if (rand(1,60) == 1) obj = instance_create(chest.x, chest.y, oBasketball);
in oPlayer1 : step : Action
Scroll down a little and you'll see a
//crate
comment
that's where you put it.

EDIT:
My bad, the comment read "open crate", not just "crate"


Title: Re: Game Maker Help Thread!
Post by: ipwnu1337 on January 07, 2010, 08:31:04 PM
I've looked through the code for a bit, but, alas, I cannot find the area that contains the fire rate for the guns. (Ahem, attempting to make a gun mod, ahem.).

Can someone more coding-savvy here help me a tad?  I am not familiar with the gamemaker language.


Title: Re: Game Maker Help Thread!
Post by: Kegluneq on January 08, 2010, 12:22:24 AM
It's in the create oPlayer1 code.

Look for firingPistolMax and firingShotgunMax.


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on January 08, 2010, 12:49:50 AM
hmm... having problems with keys opening doors, if you are holding they key the key in your hand goes away, but it's still "held", how can I fix that?


Title: Re: Game Maker Help Thread!
Post by: Kegluneq on January 08, 2010, 12:52:05 AM
Not quite sure, use the key for the Udjat Eye chest as a reference.


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on January 08, 2010, 01:06:02 AM

Quote
if (sprite_index == oMetalDoor)
{
    other.held = false;
    with oPlayer1
    {
        holdItem = 0;
        pickupItemType = "";
    }
    with other { instance_destroy(); }
    obj.xVel = rand(0,3) - rand(0,3);
    obj.yVel = -2;
    obj = instance_create(x, y, oPoof);
    with obj { xVel = -0.4; }
    obj = instance_create(x, y, oPoof);
    with obj { xVel = 0.4; }
    instance_destroy();
}
what seems to be the probelm? It just doesn't work..[/s]
and I figured it out.


Title: Re: Game Maker Help Thread!
Post by: Kegluneq on January 08, 2010, 04:49:11 PM
Whoo! Good job!


Title: Re: Game Maker Help Thread!
Post by: ipwnu1337 on January 08, 2010, 11:02:22 PM
Hrm, I've gotten the stuff to work, but how do you get the item to appear?  How do you get it to spawn?


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on January 08, 2010, 11:26:19 PM
what do you mean?


Title: Re: Game Maker Help Thread!
Post by: Darkness3313 on January 08, 2010, 11:27:08 PM
You need to use, ScrGenerateitem.


Title: Re: Game Maker Help Thread!
Post by: ipwnu1337 on January 09, 2010, 10:53:48 AM
I've gone there, and did some copying and pasting, but I still cannot get the item to spawn from the crates.  Help please?


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on January 09, 2010, 11:02:21 AM
what did you do? can you post what you messed with?


Title: Re: Game Maker Help Thread!
Post by: Darkness3313 on January 09, 2010, 11:19:36 AM
else if (rand(1,60) == 1) obj = instance_create(chest.x, chest.y, oOBJECT);
in oPlayer1 : step : Action
Scroll down a little and you'll see a
//crate
comment


Replace OBJECT with whatever you are adding.


Title: Re: Game Maker Help Thread!
Post by: ipwnu1337 on January 09, 2010, 11:34:54 AM
what did you do? can you post what you messed with?

Okay, lets see, I'm attempting to add a new gun to the game.  I've added the left and the right sprites, and added object oSubMachineGun to the objects folder.  I've also tinkered with the firingmax code, and reduced the firingmax to 1, and added the firingSubMachineGunMax to 5.  I've tried to get it to spawn through the scrGenerateItem code, but it doesn't work.


Any idea on how it to spawn from pots 100% of the time, rather than crates?


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on January 09, 2010, 11:35:54 AM
Yay machine guns!!!


Title: Re: Game Maker Help Thread!
Post by: Delver on January 09, 2010, 11:47:57 AM
what did you do? can you post what you messed with?

Okay, lets see, I'm attempting to add a new gun to the game.  I've added the left and the right sprites, and added object oSubMachineGun to the objects folder.  I've also tinkered with the firingmax code, and reduced the firingmax to 1, and added the firingSubMachineGunMax to 5.  I've tried to get it to spawn through the scrGenerateItem code, but it doesn't work.


Any idea on how it to spawn from pots 100% of the time, rather than crates?

If you go to; oJar - destroy - execute code;

if (rand(1,3) == 1) instance_create(x, y, oGoldChunk);
    else if (rand(1,6) == 1) instance_create(x, y, oGoldNugget);
    else if (rand(1,12) == 1) instance_create(x, y, oEmeraldBig);
    else if (rand(1,12) == 1) instance_create(x, y, oSapphireBig);
    else if (rand(1,12) == 1) instance_create(x, y, oRubyBig);
    else if (rand(1,6) == 1) instance_create(x-8, y-8, oSpider);
    else if (rand(1,12) == 1)
    {
        if (colLeft) instance_create(x, y-8, oSnake);
        else if (colRight) instance_create(x-16, y-8, oSnake);
        else instance_create(x-8, y-8, oSnake);
    }

change all that to;

if (rand(1,1) == 1) instance_create(x, y, oMachinePistol);

or what you called it  :)


Title: Re: Game Maker Help Thread!
Post by: ipwnu1337 on January 09, 2010, 11:54:41 AM
Ah, okay, nice.

I've got it to spawn, but all it gives is an error message, reproduced here:

___________________________________________
ERROR in
action number 1
of  Step Event
for object oItem:

Error in code at line 71:
           moveTo(xVel, yVel);
                  ^
at position 17: Unknown variable xVel


Man, I'm really bad a this.


Title: Re: Game Maker Help Thread!
Post by: Delver on January 09, 2010, 12:10:47 PM
Ah, okay, nice.

I've got it to spawn, but all it gives is an error message, reproduced here:

___________________________________________
ERROR in
action number 1
of  Step Event
for object oItem:

Error in code at line 71:
           moveTo(xVel, yVel);
                  ^
at position 17: Unknown variable xVel


Man, I'm really bad a this.

not sure, but have you remembered calling the inherited event under step for your gun?
 


Title: Re: Game Maker Help Thread!
Post by: ipwnu1337 on January 09, 2010, 12:14:34 PM
Inheirited event under what?

What is that?


Title: Re: Game Maker Help Thread!
Post by: Delver on January 09, 2010, 12:22:28 PM
It simply means it should do all the code under step; the "execute pierce of code" command, as wall as all the code of it's parent object (in this case oItem) under it's step

you can see it below (not sure if it's the problem)


Title: Re: Game Maker Help Thread!
Post by: ipwnu1337 on January 09, 2010, 12:43:37 PM
Oh, right,  I haven't filled anything in there.

And I don't know how.

[EDIT] Nevermind, I think I've got it figured out.  I'll just need to test it.

[EDIT#2]  Huh, it works, but there are a handful of problems:

The rapid-fire capibility only works when facing the left side.  Wierd.
When whipping the pot open on a level with a store, a $ sign appears over it, and you'll be accused of stealing if you pick it up, however, if you throw the pot, it won't trigger it.
The gun can't be transported through levels.

Hrm.


Title: Re: Game Maker Help Thread!
Post by: Delver on January 09, 2010, 01:10:16 PM
Oh, right,  I haven't filled anything in there.

And I don't know how.

[EDIT] Nevermind, I think I've got it figured out.  I'll just need to test it.

[EDIT#2]  Huh, it works, but there are a handful of problems:

The rapid-fire capibility only works when facing the left side.  Wierd.
When whipping the pot open on a level with a store, a $ sign appears over it, and you'll be accused of stealing if you pick it up, however, if you throw the pot, it won't trigger it.
The gun can't be transported through levels.

Hrm.


sound pretty good, the fire bug, is properly because you only changed the first part of the code, below that - should be a facing right; you need to change that to.

the code under oJar, change it like this;
if (rand(1,1) == 1)
{
obj = instance_create(x, y, oMachinePistol);
obj.cost = 0;
obj.forSale = false;
}

when the gun spawns, it will no longer be on sale

under your object create event it should have a type - like this;

type = "Shotgun";
makeActive();
setCollisionBounds(-4, -4, 4, 4);
cost = 15000;
buyMessage = "A SHOTGUN FOR $" + string(cost) + ".";

you need to add that type to scrHoldItem - like this;

else if (itemType == "Shotgun") holdItem = instance_create(x, y, oShotgun);

this will make the Item spawn in your hand in the next level

and that should be it  :)


Title: Re: Game Maker Help Thread!
Post by: ipwnu1337 on January 09, 2010, 01:50:32 PM
Ah, ok, that solves all the problems.

The only other problem, though mostly visual, is that the submachinegun appears to be off-centered, and lookslike the spelunker is holding it with his foot, though the bullet comes out where it usually should.  I'm sure it's not problems with the sprite itself, and I copied and pasted all the code for the item from the pistol and shotgun.

Wierd.


Title: Re: Game Maker Help Thread!
Post by: Delver on January 09, 2010, 01:55:41 PM
nicely done  :)

might be your sprites center thats of:


Title: Re: Game Maker Help Thread!
Post by: hyperme on January 09, 2010, 02:00:11 PM
How would I check if an idol has been picked up?


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on January 09, 2010, 02:04:27 PM
Not sure,

Something to do with holdItem

what are you trying to do?


Title: Re: Game Maker Help Thread!
Post by: ipwnu1337 on January 09, 2010, 02:06:48 PM
I'm thinking he's trying to recreate the idol traps from the main game.


Title: Re: Game Maker Help Thread!
Post by: hyperme on January 09, 2010, 02:09:44 PM
Yep.  I think I can do it by duplicating the TikiHead, and changing the alarm event to a trigger.


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on January 09, 2010, 07:11:51 PM
Make sure you make ALL of the traps


Title: Re: Game Maker Help Thread!
Post by: Kitoari on January 10, 2010, 02:11:56 PM
I'm trying to find the script/code section that handles adding collectibles, but I can't find it. Any help?


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on January 10, 2010, 02:16:02 PM
Where are you trying to add it?


Title: Re: Game Maker Help Thread!
Post by: Kitoari on January 10, 2010, 02:21:53 PM
Nowhere, I want to find where it was originally so I can keep things organized.


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on January 10, 2010, 02:33:36 PM
... I am not sure what you are asking


Title: Re: Game Maker Help Thread!
Post by: ipwnu1337 on January 10, 2010, 05:07:16 PM
Is there any way to change the amount of recoil that a gun gives?

Because I'm making another gun that has extremely high recoil, so I want it to be able to push the spelunker back a bit more.

In addition, for some reason, the gun I'm making always drops to the floor when the spelunker goes through a level, as in I'm holding the gun when I go through the door, and when I exit the door, the gun drops to the ground at the spelunker's feet.

Help please?


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on January 10, 2010, 05:09:16 PM
Heavy=false


Title: Re: Game Maker Help Thread!
Post by: ipwnu1337 on January 10, 2010, 05:24:25 PM
I mean, when the spelunker goes through a level, the gun drops to his feet in the NEXT level.

So in other words:

Level 1:

I have my gun, I walk through door.

Level 2:

I don't have my gun in my hands, it's on the floor next to me.

In addition, how do you decrease teh bullet damage?


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on January 10, 2010, 06:32:30 PM
ah,,, right. Give me a while


Title: Re: Game Maker Help Thread!
Post by: DariusK on January 11, 2010, 09:03:05 AM
How would I check if an idol has been picked up?
Here's how the idol works.

If you want to know when the player actually triggers the trap for the gold idol being picked up the first time, you need to look in the oPlayer1 object, in the Step event, in the second Action, around line 830. You'll see the folliwing code, as part of the generic code for what happens when you press down and attack and there's an item on the ground:

Code:
                if (holdItem.type == "Gold Idol" and holdItem.trigger and not isRoom("rLoadLevel"))
                {
                    global.idolsGrabbed += 1;
                    // INSERT CODE TO RUN THE FIRST TIME YOU PICK UP ANY IDOL
                    if (global.levelType == 0)
                    {
                        trap = instance_nearest(x, y-64, oGiantTikiHead);
                        with trap { alarm[0] = 100; }
                        scrShake(100);
                        holdItem.trigger = false;
                    }
                    else if (global.levelType == 1)
                    {
                        if (global.cemetary and not global.ghostExists)
                        { 
                            if (oPlayer1.x > room_width / 2)
                               instance_create(view_xview[0]+view_wview[0]+8,
                               view_yview[0]+floor(view_hview[0] / 2), oGhost);
                            else instance_create(view_xview[0]-32,
                               view_yview[0]+floor(view_hview[0] / 2), oGhost);
                            global.ghostExists = true;
                        }
                        with oTrapBlock
                        {
                            dist = distance_to_object(oCharacter);
                            if (dist < 90)
                            {
                                dying = true;
                                //instance_destroy();
                            }
                        }
                    }
                    else if (global.levelType == 3)
                    {
                        if (instance_exists(oCeilingTrap))
                        {
                            with oCeilingTrap
                            {
                                status = 1;
                                yVel = 0.5;
                            }
                            scrShake(20);
                            trap = instance_nearest(x-64, y-64, oDoor);
                            trap.status = 1;
                            trap.yVel = 1;
                            trap = instance_nearest(x+64, y-64, oDoor);
                            trap.status = 1;
                            trap.yVel = 1;
                        }
                        else
                        {
                            with oTrapBlock
                            {
                                dist = distance_to_object(oCharacter);
                                if (dist < 90)
                                {
                                    instance_destroy();
                                }
                                playSound(global.sndThump);
                                scrShake(10);
                            }
                        }
               
                        holdItem.trigger = false;
                    }
                }
You probably only care about the holdItem.trigger variable. The opening IF statement means, "if the item you just picked up and are now holding (holdItem) is set to be a trigger, and you're not in a custom level, then set off all these traps depending on what area of the game you're in."

So if you wanted to trigger something when you pick up the Idol for the first time, you would want to put the code right after the IF statement open bracket. If you want something different to happen in each area (such as modifying the way the traps work), you can modify what happens in each of the following IF statements where they check for global.LevelType.

Now if you just want to check and see if the player is holding the item, that's easy, it's just a matter of checking if holdItem.type == "Gold Idol" in the oPlayer1 object.


Title: Re: Game Maker Help Thread!
Post by: DrSakuyaPhD on January 16, 2010, 11:46:42 AM
I'm trying to add in a radar type items that locates objects of interest and draws in on the screen (like the compass, but instead of the exit stuff like enemies, damsels, traps, etc.) I can do the finding and drawing code, but there's one part I can't find. In what section of code does it handle the picking up of items, and setting the variable that tells the HUD to draw the item, e.g. global.hasCompass?


Title: Re: Game Maker Help Thread!
Post by: Kegluneq on January 16, 2010, 01:44:05 PM
Seeing as I'm having item trouble with my multiplayer mod, I'd like to know the answer to that^ question as well.


Title: Re: Game Maker Help Thread!
Post by: Kitoari on January 16, 2010, 02:21:20 PM
Me third for that answer.


Title: Re: Game Maker Help Thread!
Post by: Delver on January 16, 2010, 02:23:11 PM
there is a couple of scripts under the character folder.

scrHoldItem (believe this one recreates the holdItem when passing a level))
scrDropItem (might be useful)
scrDrawHUD (sets the HUD, showing Item picked up (controls the compass arrow))

scrUseItem (simply controls what happens when using an Item (modified it a lot for the potion mod))

your properly already know about the above.



 


Title: Re: Game Maker Help Thread!
Post by: hyperme on January 16, 2010, 02:30:20 PM
How do I make the thwomp trap deadly?  As in, the bottom can crush you while falling, and you can be crushed between it and an object when it rises


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on January 16, 2010, 02:59:45 PM
Um... what? It already is?


Title: Re: Game Maker Help Thread!
Post by: hyperme on January 16, 2010, 03:05:05 PM
Go underthe Traps folder in objects.  There is a Thwomp Trap.


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on January 16, 2010, 03:07:24 PM
yes. yes there is. what about it?


Title: Re: Game Maker Help Thread!
Post by: hyperme on January 16, 2010, 03:18:51 PM
It is harmless.  How do i make it unharmless?


Title: Re: Game Maker Help Thread!
Post by: Kegluneq on January 16, 2010, 03:35:50 PM
mgg, you're thinking about the SmashTrap. (Which, hyperme, you should know: We here at mossmouth have dubbed the SmashTrap the Thwomp)

Thwomp Trap is a different trap, very similar to the thwomps in the mario series.

hyperme, you just sit tight, I'm on it!

EDIT:
Copy this into the first hurt script in oPlayer1:
Code:
obj = collision_rectangle(x-2, y-9, x+2, y-7, oThwompTrap, 0, 0)
if (obj)
{
    if (obj.status > 0)
    {
        if (global.plife > 0 and isRealLevel()) global.miscDeaths[9] += 1;

        global.plife -= 10;
        scrCreateBlood(x, y, 1);
    }
}
Then, go into the step code for oThwompTrap, and put this in the very beginning:
Code:
if (x > view_xview[0]-16 and x < view_xview[0] + view_wview[0]+16 and
        y > view_yview[0]-16 and y < view_yview[0] + view_hview[0]+16)
{
Don't forget to put an end bracket at the very end!
Finally, replace
Code:
if (oPlayer1.y > y and dist < 96 and abs(oPlayer1.x - x) < 8)
with
Code:
if (oPlayer1.y > y and dist < 96 and abs(oPlayer1.x - (x+8)) < 16)

And that takes care of getting hurt by the fall, and fixes the trap up a little bit.

I'm not quite sure what to do for the crush between the trap coming back up and a ceiling, but I'll tel you as soon as I find out!


Title: Re: Game Maker Help Thread!
Post by: Sudonimus on January 16, 2010, 03:44:53 PM
Don't we call 'em SpikeBLocks?


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on January 16, 2010, 03:48:50 PM
spike blocks gets the idea acrost, but thromp is what I normaly call them


Title: Re: Game Maker Help Thread!
Post by: Sudonimus on January 16, 2010, 03:53:15 PM
I used "Thwomp" in my first custom level.
The "Mario" series.


Title: Re: Game Maker Help Thread!
Post by: Kirby on January 16, 2010, 03:59:20 PM
Alright, need to know how to make a tile like water but you sink down more slowly, and it covers you like lava.


Title: Re: Game Maker Help Thread!
Post by: Kegluneq on January 16, 2010, 04:10:12 PM
Go back to my last post (http://mossmouth.com/forums/index.php?topic=586.msg15404#msg15404) to discover my solution to the Thwomp problem!


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on January 16, 2010, 04:23:13 PM
Alright, need to know how to make a tile like water but you sink down more slowly, and it covers you like lava.
coving you would be easy... just make it over the hero sprite? quick sane right?


Title: Re: Game Maker Help Thread!
Post by: Kegluneq on January 16, 2010, 04:24:07 PM
I gave it a shot, but it's more complex than I thought...


Title: Re: Game Maker Help Thread!
Post by: Kirby on January 16, 2010, 07:09:11 PM
How would I go about editing the rooms that spawn and make paths in game?


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on January 16, 2010, 07:12:56 PM
http://mossmouth.com/forums/index.php?topic=628.0

this answers you question oh lord of kibry


Title: Re: Game Maker Help Thread!
Post by: Kirby on January 16, 2010, 07:17:17 PM
http://mossmouth.com/forums/index.php?topic=628.0

this answers you question oh lord of kibry

THANKS I can probably do a lot with this...


Title: Re: Game Maker Help Thread!
Post by: Arucard on January 18, 2010, 02:32:44 PM
I've hit a snag with the Shopkeeper. The limited ammo is implemented and working fine, but there are two issues I would like to resolve before another release:

1. is purely cosmetic, I can't figure how to get the shotgun sprite to draw only when firing and only when the ammo is >0. I've tried setting it a few places with some interesting results at times, and the closest I've come is to have it appear for a brief second, but before the shot is fired. It doesn't look bad without it, but if I can get it in there I'd like to.

2. is implicit to gameplay, as it stands you will start the game with 7 shells. I have added an item (box of shells) to give 7 more and put it in the shop/box lists. I can't tell if it's not showing up, or if it's giving me bombs instead since I copied and edited the functions from the bomb bag. I also want to take the shotgun out entirely, but that may have to wait until the shells are at least working. The biggest issue I'm having is where to find the functions of items? Is it simply in the hold item script? Steal item?

Anyway, if you can help thanks, I'm about to give in.


Title: Re: Game Maker Help Thread!
Post by: Kegluneq on January 19, 2010, 04:12:38 PM
More item trouble, this seems to be the bane of everyone's mod right now.


Title: Re: Game Maker Help Thread!
Post by: Darkness3313 on January 19, 2010, 08:11:12 PM
And then the answers to everyones questions layed upon us and drew us near and he explained, oh yes he did.








not really.

But seriously, I have a question,
In my Yeti Mod, I'm trying to make it so the Yetis attack is a throw, my question, how do I activate it in the oAction script? I'm not too sure on how to work this.
(Going along well though)

EDIT: Not oAction, the action coding in the oPlayer object.


Title: Re: Game Maker Help Thread!
Post by: DariusK on January 20, 2010, 08:53:25 AM
I can't figure how to get the shotgun sprite to draw only when firing and only when the ammo is >0

In the script scrUseItem, line 245,  you see this:

Code:
            if (not scrPlayerIsDucking())
            {
            if (facing == LEFT and firing == 0)
            {
                instance_create(x-9, y+1, oShotgunBlastLeft);
                obj = instance_create(x-9, y-2, oBullet);
                obj.xVel = (-1 * rand(6,8)) + xVel;
                if (obj.xVel >= -6) obj.xVel = -6;
                obj.yVel = 0;
                if (state != HANGING and state != CLIMBING)
                {
                    yVel -= 1;
                    xVel += 1;
                }
                playSound(global.sndShotgun);
                firing = firingPistolMax;
            }

Just add another clause to the if statement, like "and global.ammo > 0". I'm assuming you're using a global ammo variable since that's how bombs and ropes are tracked, plus it'll make it easier to add a new UI element (see below).

You'll want to do the same thing to line 260, which is the same code but for when you're facing right.

Specifically, it's when the game creates oShotgunBlastLeft and oShotgunBlastRight that it displays the muzzle flashes. So you could also put an "if (global.ammo > 0) right before the instance_create for those objects as well.

2. is implicit to gameplay, as it stands you will start the game with 7 shells. I have added an item (box of shells) to give 7 more and put it in the shop/box lists. I can't tell if it's not showing up, or if it's giving me bombs instead since I copied and edited the functions from the bomb bag. I also want to take the shotgun out entirely, but that may have to wait until the shells are at least working. The biggest issue I'm having is where to find the functions of items? Is it simply in the hold item script? Steal item?

Most of the code for what happens when you're holding and using an item is in scrUseItem. That's for active items like guns and the machete and the damsel. What you might want to do is add a new UI element to the top of the screen that shows how much ammo you have -- that way you can tell if your box of shells is working or not. To do this, open up scrDrawHUD and you'll see this:
Code:
if (global.drawHUD and instance_exists(oPlayer1))
{
    lifeX = 8;
    bombX = 64;
    ropeX = 120;
    moneyX = 176;
    draw_set_font(global.myFont);
    draw_set_color(c_white);
    draw_sprite(sHeart, -1, lifeX, 8);
    life = global.plife;
    if (life < 0) life = 0;
    draw_text(lifeX+16, 8, life);
    if (global.hasStickyBombs) draw_sprite(sStickyBombIcon, -1, bombX, 8);
    else draw_sprite(sBombIcon, -1, bombX, 8);
    draw_text(bombX+16, 8, global.bombs);
    draw_sprite(sRopeIcon, -1, ropeX, 8);
    draw_text(ropeX+16, 8, global.rope);
    draw_sprite(sDollarSign, -1, moneyX, 8);
    draw_text(moneyX+16, 8, global.money);

What you'll want to do is create ammoX, which is the X offset of the new ammo UI element. I would actually put it in between rope and money, because money is variable length so you want it at the far right hand side. Then you just add the draw_text() and draw_sprite() functions. I used the sprite for the shotgun in the example below:

Code:
if (global.drawHUD and instance_exists(oPlayer1))
{
    global.ammo = 7; // CHANGE THIS ELSEWHERE IN THE CODE, this is just for test purposes
    lifeX = 8;
    bombX = 64;
    ropeX = 120;
    ammoX = 176;
    moneyX = 232;
    draw_set_font(global.myFont);
    draw_set_color(c_white);
    draw_sprite(sHeart, -1, lifeX, 8);
    life = global.plife;
    if (life < 0) life = 0;
    draw_text(lifeX+16, 8, life);
    if (global.hasStickyBombs) draw_sprite(sStickyBombIcon, -1, bombX, 8);
    else draw_sprite(sBombIcon, -1, bombX, 8);
    draw_text(bombX+16, 8, global.bombs);
    draw_sprite(sRopeIcon, -1, ropeX, 8);
    draw_text(ropeX+16, 8, global.rope);
    // I had to fiddle a bit with the x and y vars here to make things look good
    draw_sprite(sShotgunRight, -1, ammoX, 16);
    draw_text(ammoX+8, 8, global.ammo);
    draw_sprite(sDollarSign, -1, moneyX, 8);   
    draw_text(moneyX+16, 8, global.money);
(http://tinysubversions.com/spelunky/s6.PNG)



Title: Re: Game Maker Help Thread!
Post by: DariusK on January 20, 2010, 08:54:52 AM
Of course, I just noticed that Arucard already fixed his problems!

I guess I'll take the post I just did and post it as a mini-tutorial on how to implement a new inventory item type.


Title: Re: Game Maker Help Thread!
Post by: Arucard on January 20, 2010, 12:07:14 PM
Of course, I just noticed that Arucard already fixed his problems!

I guess I'll take the post I just did and post it as a mini-tutorial on how to implement a new inventory item type.
Mostly, anyway. I had already done the bulk of what you suggested with a global ammo, drawing on the HUD, etc. I still need to figure where to set the function for drawing the sprite in his hand temporarily when shooting. I think I could make it show up the whole time he has ammo, but picking up other items would look silly.

I put this in the draw event of the player object, and ended up at one point getting a brief glimpse of the gun, but only the split second after pushing the button. I guess my confusion is in the drawing of sprites, if I make a seperate script and have that script checked when pressing attack might that work? Or is it limited to the draw event?

Code:
kAttackPressed = checkAttackPressed ()
if (kAttackPressed and global.ammo >0 and facing == LEFT and !scrPlayerIsDucking)
{
draw_sprite (sShotgunLeft,0,x-6,y+1)
}
    else if (kAttackPressed and global.ammo >0 and facing == RIGHT and !scrPlayerIsDucking)
{
draw_sprite (sShotgunRight,0,x+8,y+1)
}
P.S. the coordinates on that may be wonky, I thought it was showing up right under the blast and tried to get it out of the way.  :P


Title: Re: Game Maker Help Thread!
Post by: DariusK on January 20, 2010, 01:02:19 PM
I put this in the draw event of the player object, and ended up at one point getting a brief glimpse of the gun, but only the split second after pushing the button.
What you want is to put in a timer somewhere. There are plenty of examples of timers all over the code, but basically when the gun is fired you want to set showShotgunTimer = 1000 (or whatever value), and then something like

Code:
if (kAttackPressed and global.ammo >0 and facing == LEFT and !scrPlayerIsDucking and showShotgunTimer > 0)
{
draw_sprite (sShotgunLeft,0,x-6,y+1);
showShotgunTimer -= 1;
}


Title: Re: Game Maker Help Thread!
Post by: Arucard on January 20, 2010, 02:57:56 PM
Alright thanks, I'll see if I can get that to work. It's funny the stuff I was able to figure out and this freaking sprite not showing up is what's really killing me.  :(


Title: Re: Game Maker Help Thread!
Post by: Kegluneq on January 20, 2010, 03:03:48 PM
Okay then, my turn.

I need help finding where the code for picking up items is.
I've looked everywhere (everywhere that isn't where what I need is) and can't find it, anyone know the exact location?


Title: Re: Game Maker Help Thread!
Post by: DariusK on January 20, 2010, 03:12:09 PM
If you mean the code where you press down and attack and pick something up, it is in the oPlayer1 object, in the Step Event, in the second block of code, line 807. It starts like this:

Code:
    else if (kAttackPressed and kDown)
    {
        // pick up item
        if (collision_rectangle(x-8, y, x+8, y+8, oItem, 0, 0))
        {
            obj = instance_nearest(x, y, oItem);
            if (obj.canPickUp and not collision_point(obj.x, obj.y, oSolid, 0, 0))
            {
                holdItem = obj;
                holdItem.held = true;
                whoaTimer = whoaTimerMax;
                pickupItemType = holdItem.type;

That's the code that says "if I'm pressing down and attack and I'm on top of an object, set my holdItem to that object and set that object's 'held' variable to be true."


Title: Re: Game Maker Help Thread!
Post by: Kegluneq on January 20, 2010, 03:34:34 PM
There it is! Such a small block of code, I imagined it would of been a little bigger.

Thanks a lot!
Now the MP mod can get back under development!


Title: Re: Game Maker Help Thread!
Post by: hyperme on January 21, 2010, 03:33:12 PM
How do I make something a light source for dark levels?  The next release of SE+ depends on this!


Title: Re: Game Maker Help Thread!
Post by: DariusK on January 21, 2010, 03:49:23 PM
It's in the oScreen object, in the Begin Step event, line 156.

Code:
  else if (isLevel() and instance_exists(oPlayer1))
    {
        if (global.darkLevel and not oPlayer1.dead)
        {
            surface_set_target(darkSurf);
            draw_set_color(c_black);
            draw_rectangle(0, 0, screen_w, screen_h, false);
            draw_set_color(make_color_rgb(255-255*oLevel.darkness,255-255*oLevel.darkness,255));
            if (instance_exists(oLampRed))
            {
                with oPlayer1
                {
                    distToLamp = distance_to_object(oLampRed);
                    if (distToLamp <= 96)
                    {
                        draw_set_color(make_color_rgb(255-distToLamp,120-(96-distToLamp),120-(96-distToLamp)));
                    }
                }
            }
            if (instance_exists(oLampRedItem))
            {
                with oPlayer1
                {
                    distToLamp = distance_to_object(oLampRedItem);
                    if (distToLamp <= 96)
                    {
                        draw_set_color(make_color_rgb(255-distToLamp,120-(96-distToLamp),120-(96-distToLamp)));
                    }
                }
            }
            draw_circle(oPlayer1.x-view_xview[0], oPlayer1.y-view_yview[0], 96-64*oLevel.darkness, false);
            with oFlare
            {
                draw_circle(x-view_xview[0], y-view_yview[0], 96, false);
            }
            with oFlareCrate
            {
                draw_circle(x-view_xview[0], y-view_yview[0], 96, false);
            }
            with oLamp
            {
                draw_circle((x+8)-view_xview[0], (y+8)-view_yview[0], 96, false);
            }
            with oLampItem
            {
                draw_circle(x-view_xview[0], (y-4)-view_yview[0], 96, false);
            }
            with oArrowTrapLeftLit
            {
                draw_circle((x+8)-view_xview[0], (y+8)-view_yview[0], 32, false);
            }
            with oArrowTrapRightLit
            {
                draw_circle((x+8)-view_xview[0], (y+8)-view_yview[0], 32, false);
            }
            with oTikiTorch
            {
                draw_circle((x+8)-view_xview[0], (y+8)-view_yview[0], 32, false);
            }
            with oFireFrog
            {
                draw_circle((x+8)-view_xview[0], (y+8)-view_yview[0], 32, false);
            }
            with oSpearTrapLit
            {
                draw_circle((x+8)-view_xview[0], (y+8)-view_yview[0], 32, false);
            }
            with oSmashTrapLit
            {
                draw_circle((x+8)-view_xview[0], (y+8)-view_yview[0], 32, false);
            }
            with oExplosion
            {
                draw_circle(x-view_xview[0], y-view_yview[0], 96, false);
            }
            with oLava
            {
                draw_circle((x+8)-view_xview[0], (y+8)-view_yview[0], 32, false);
            }
            with oScarab
            {
                draw_circle((x+8)-view_xview[0], (y+8)-view_yview[0], 16, false);
            }
            with oGhost
            {
                draw_circle((x+16)-view_xview[0], (y+16)-view_yview[0], 64, false);
            }
            surface_set_target(screen);
            draw_set_blend_mode_ext(bm_dest_color, bm_zero);
            draw_set_alpha(1);
            draw_surface(darkSurf, 0, 0);
            draw_set_blend_mode(bm_normal);
        }

If you want it to just light up like a scarab or whatever, you can just add:

Code:
           with oYourObject
            {
                draw_circle((x+8)-view_xview[0], (y+8)-view_yview[0], YOURSIZEHERE, false);
            }

Where YOURSIZEHERE is the radius of the circle in 16-pixel tiles (so a value of 16 would illuminate two tiles all around from the center, 8 would just illuminate the one tile, etc).

If you want it to behave more like a lamp, where the closer you get the brighter the screen gets, you'll just want to copy the lamp code:

Code:
if (instance_exists(oYourObject))
            {
                with oPlayer1
                {
                    distToLamp = distance_to_object(oYourObject);
                    if (distToLamp <= 96)
                    {
                        draw_set_color(make_color_rgb(255-distToLamp,120-(96-distToLamp),120-(96-distToLamp)));
                    }
                }
            }


Title: Re: Game Maker Help Thread!
Post by: Arucard on January 22, 2010, 08:57:09 AM
This is why your nick-name is now Proffessor K.  ;D


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on January 22, 2010, 04:01:26 PM
Dr. K sounds better


Title: Re: Game Maker Help Thread!
Post by: Kirby on January 22, 2010, 04:54:14 PM
Anyone know where the sprite for the rubble on top of blocks are?

Like the cave, lush, ice, temple blocks. There's some rubble on top that I can't seem to find the sprite for.


Title: Re: Game Maker Help Thread!
Post by: Arucard on January 22, 2010, 07:06:55 PM
You mean the little bumpy stuff that forms on top of the blocks?(in each level's folder under Block ending with the suffix "top") Or the actual rubble left when they are destroyed? (under the "effects" folder starting with sRubble)


Title: Re: Game Maker Help Thread!
Post by: Kirby on January 22, 2010, 08:16:49 PM
Both, thanks for your help. Going to finish up this mod now.


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on January 22, 2010, 08:29:14 PM
help! my bomb rock doesn't seem to work right. How would one make a rock that blows up when ever it stops, and goes flying then stops when it lands, and then blows up and keeps going?


Title: Re: Game Maker Help Thread!
Post by: Kirby on January 22, 2010, 08:50:46 PM
You mean the little bumpy stuff that forms on top of the blocks?(in each level's folder under Block ending with the suffix "top") Or the actual rubble left when they are destroyed? (under the "effects" folder starting with sRubble)
I changed both of them, but the top is still brown. Any idea why?


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on January 22, 2010, 09:02:20 PM
Um... change backgrounds, there is some stuff there.


Title: Re: Game Maker Help Thread!
Post by: Kegluneq on January 22, 2010, 09:13:43 PM
help! my bomb rock doesn't seem to work right. How would one make a rock that blows up when ever it stops, and goes flying then stops when it lands, and then blows up and keeps going?

Code:
if (xVel = 0 and yVel = 0)
    make an explosion

Right?


Title: Re: Game Maker Help Thread!
Post by: Arucard on January 22, 2010, 09:15:16 PM
You'd probably want some timer in there too though right?


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on January 22, 2010, 09:26:37 PM
help! my bomb rock doesn't seem to work right. How would one make a rock that blows up when ever it stops, and goes flying then stops when it lands, and then blows up and keeps going?

Code:
if (xVel = 0 and yVel = 0)
    make an explosion

Right?
Thats what I have. makes a flying rock that doesn't go bomb and hurts you which some times can be picked up and some times not. If it can be picked it, it kills you to do so.


Title: Re: Game Maker Help Thread!
Post by: MagiMaster on January 23, 2010, 02:34:24 AM
It's very likely that the velocity will never be exactly 0, unless you pick the item up, which would force it to be 0. Instead, you should check if the velocity is close to 0.

Try this, though you might have to adjust the cutoff point.
Code:
if(xVel*xvel + yVel*yVel < 0.001)
    ...


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on January 23, 2010, 02:45:35 AM
It's very likely that the velocity will never be exactly 0, unless you pick the item up, which would force it to be 0. Instead, you should check if the velocity is close to 0.

Try this, though you might have to adjust the cutoff point.
Code:
if(xVel*xvel + yVel*yVel < 0.001)
    ...

I would of thought that, but... my velocity check works with arrows just fine! remember the bomb arrows? same check. remember they arrows that destroy themselves in evil death? same check...
I think it's something to do with the rock itself.
(also the velocity well be exactly 0 a lot, when ever they are on the ground, I checked, game maker rarely has such a problem)


Title: Re: Game Maker Help Thread!
Post by: MagiMaster on January 23, 2010, 05:40:14 AM
It would seem to explain why it blows up randomly, but it's just a guess.


Title: Re: Game Maker Help Thread!
Post by: DariusK on January 23, 2010, 07:50:14 AM
Most (probably all) objects do actually resolve to x/y velocity of 0 when they're stopped. If you are having trouble debugging it, you can put in this code in the oBombRock Draw event (and change the included variables to anything you want, really):

Code:
    draw_set_font(global.myFontSmall);
    draw_set_color(c_white);
    draw_text(x+16,y-16, string(xVel) + ", " + string(yVel));

This way you can make sure that your trigger variables are correct.


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on January 23, 2010, 11:22:23 AM
It would seem to explain why it blows up randomly, but it's just a guess.
It doesn't blow up at all... or move. just kill me.

but thanks for the check DariusK, I'll use it.


Title: Re: Game Maker Help Thread!
Post by: ipwnu1337 on January 23, 2010, 12:08:56 PM
My turn?

Anyway, is there a way to add a new action button?  I'm thinking of creating a new mod, but it requires that I can use right-hand and left-hand weapons.


Title: Re: Game Maker Help Thread!
Post by: DariusK on January 23, 2010, 12:49:21 PM
Sure. If you're going to do this totally properly, you would need to edit the config.exe to provide a new keybinding (so people can set your new action key to whatever they want). Writing proper controls where gamepads, joysticks, and keyboards all work the way you expect them to and can be bound to different values is a HUGE thing and I don't want to write up a whole tutorial on that. So I'll skip that and just assume you want to hardcode a new key. So let's say you want 'V' to be a button that creates a yeti. I dunno why you'd want to do that, but let's just say you did :)

First you go to the scrInit script and add a new global. You'll see all these global.key**** values. Add a new one, something like

Code:
global.keyYetiVal = ord('V');

There's some gamepad code underneath that, and there's more code under that for importing key values from the config files. But like I said, I'm not covering that.

Next you'll see there's a bunch of scripts under the "Control" directory, stuff like checkAttack, checkAttackPressed, checkAttackReleased. Copy those three but rename them checkYeti, checkYetiPressed, checkYetiReleased. Then in each one of those you modify them to look like this, by commenting out the first three lines and replacing the attack global with your new yeti global:

Code:
//if (gamepad.attack)
//    return gamepad.attack;
//else
    return (keyboard_check(global.keyYetiVal));

Again, if we were doing gamepad stuff this would break everything, but leaving it in without doing proper gamepad code will screw things up.

Actions are handled in the oPlayer1 Step event, in the second block of code. What you put here really depends on how you want your button to behave. But let's assume our Yeti spawning behaves like attacking does: you can't do it when you're ducking or transitioning from a hang, or if you're already attacking, or exiting a level. So we'll insert our code where I indicate below, at line 805:

Code:
    if (kAttackPressed and state != DUCKING and state != DUCKTOHANG and not whipping and
        sprite_index != sPExit and sprite_index != sDamselExit)
    {
        image_speed = 0.6;
        if (global.isTunnelMan)
        {
            if (platformCharacterIs(ON_GROUND))
            {
                sprite_index = sTunnelAttackL;
                image_index = 0;
                whipping = true;
            }
        }
        else if (global.isDamsel)
        {
            sprite_index = sDamselAttackL;
            image_index = 0;
            whipping = true;
        }
        else
        {
            sprite_index = sAttackLeft;
            image_index = 0;
            whipping = true;
        }
    }
    // BEGIN NEW CODE
    else if (checkYetiPressed() and state != DUCKING and state != DUCKTOHANG and not whipping and
        sprite_index != sPExit and sprite_index != sDamselExit)
    {
       //// YOUR STUFF HERE
    }   
    // END NEW CODE
    else if (kAttackPressed and kDown)
    {
        // pick up item
        if (collision_rectangle(x-8, y, x+8, y+8, oItem, 0, 0))
        {
           ...

So, yeah. That's the quick and dirty way, but again, it'll take a lot more work to make the keys rebindable and working on all sorts of controllers. I may write a tutorial about that some day. But it's boring. You know what is NOT boring? A video of my yeti-launching Spelunky mod :)

http://www.youtube.com/watch?v=rPOXbLp73oM


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on January 23, 2010, 12:53:52 PM
I am going to make a mode where you don't whip. you fire dead things at people,.


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on January 23, 2010, 12:55:15 PM
Dead things?


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on January 23, 2010, 01:09:27 PM
Yes. things that are dead.


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on January 23, 2010, 01:22:05 PM
Like dead damsels and stuff?


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on January 23, 2010, 01:43:14 PM
No dead rocks.

Yes I do mean like dead damsels and yetis and stuff.


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on January 23, 2010, 01:52:29 PM
What else are u putting in the mod?


Title: Newb is me
Post by: banna8 on January 25, 2010, 08:55:52 AM
Ok, I just recently got pro, and wanted to start editing/modding spelunky. I was using primarily drag and drop before.
I'm looking for the parts of the code involving input. (walking,running,jumping,ducking......) I have already found the attack ones though! (I think)


EDIT: Maybe I got it, its in scripts right? Sorry, I was looking in objects.


Title: Re: Game Maker Help Thread!
Post by: DariusK on January 25, 2010, 09:20:53 AM
There is a script called "characterStepEvent" that is called from inside the oPlayer1 object's step event. This reads all the input in terms of up/down/left/right movement.


Title: Ok....
Post by: banna8 on January 25, 2010, 10:20:34 AM
Thanks, I went to the characterStepEvent script, and inserted this:

Code:
if (kJumpPressed and global.isDamsel and yVel >= 0 and float > 0)
{  
     yVel = 0
     yAcc = 0
     float = float - 1
     sprite_index = sDamselHoldL
}
  

I also made it that you automatically are Damsel (global.isDamsel is true)
and put this in the oPlayer1 step code:

Code:
if (global.isDamsel and platformCharacterIs(ON_GROUND))
{
    float = 300
}

and this in characterCreateEvent :

Code:
float = 0

I spawn as Damsel (as hoped), but it effectively stops me from jumping, instead of allowing me to float at the peak of my jump (as planned). Please Help!

EDIT: also something weird happens with the whip..
all whip, and then act as if I was floating(as planned) but on the ground :(


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on January 25, 2010, 12:08:18 PM
well thatch because you start floting as soon as you press the jump key! you need some kind if (whatever state there is for in the air) so you have to double press it to float.


Title: Thanks!
Post by: banna8 on January 25, 2010, 12:28:34 PM
I changed the code to this, and now it works.(except for the sprite change)

One more thing, I made a lipstick object that she spawns with, and shows up on HUD, via DariusK's tutorial, and it works great. At the moment however, it works like a throwable object,(which is realistic) I was wondering how I could make it fire a projectile. (I'm new to the whole scripting side of GM obviously)


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on January 25, 2010, 12:36:55 PM
lipstick fire a projectile?
huh?

Well you could copy the gun code for it...


Title: Yeah...
Post by: banna8 on January 25, 2010, 12:42:53 PM
If you count a kiss-heart as a projectile, then yes! I'll try that.

aaannndd... back to the floating thing. It works (i'm amazed) But there's a bug and I dont know what triggers it. Sometimes (seemingly randomly) I'll be stuck in the sitting animation(the one selected for floating), and will be unable to attack, pickup, or throw. I can still jump, glide, and climb ladders though.

It might need to be noted that I go into the sitting sprite ONLY when this happens.


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on January 25, 2010, 12:50:16 PM
I... have no clue. sorry! but yeah copying the gun code should work

(did you check you PMs? I sent  you one)


Title: Re: Thanks!
Post by: DariusK on January 25, 2010, 12:56:11 PM
One more thing, I made a lipstick object that she spawns with, and shows up on HUD, via DariusK's tutorial, and it works great.
Glad you found my tutorial useful  ;D


Title: I think I'm Close
Post by: banna8 on January 25, 2010, 02:00:32 PM
In the step event of oPlayer1, I have this:

Code:
if(holdItem)
{
    if(holdItem.type == "Lipstick" and firing == 0 and kAttackPressed and facing == RIGHT);
}

and when I'm holding my lipstick, I get this error:

Code:
ERROR in
action number 1
of End Step Event
for object olipstick:

Error in code at line 1:
   if (holdItem.type == "Lipstick" and firing == 0 and kAttackPressed and facing == RIGHT);
      ^
at position 5: Unknown variable holdItem

What'd I do wrong?  Can I set the holdItem.type for my Lipstick?


Title: Re: Game Maker Help Thread!
Post by: Arucard on January 25, 2010, 03:06:56 PM
Hold item only refers to an in-game object you would pick up. I think it also has to be defined in another script, (scrHoldItem or something of the like) but not sure. Did you change it to something you switch to with the item select? As in Darius' tutorial?

It also seems from your code it is placed in the step event of the lipstick object, you should probably have it in the action code of the oPlayer1 step event.


Title: Help
Post by: banna8 on January 25, 2010, 03:11:10 PM
yes, I did make it with Darius's tutorial.
 I had similar code in the step event for oPlayer1, but I tried to put it in the lipstick aswell  so it would dissapear after use.


Title: Re: Game Maker Help Thread!
Post by: Arucard on January 25, 2010, 03:29:15 PM
Try commenting it out, or removing the code in the oLipstick, and add it to the items in the scrHoldItem. Chances are you'll just have to toy around with it, adding and taking things away until you get the right config. Keep looking at the scripts for items that are similar to what you want it to do. Copy some of them into an external text document so you can look at them and compare to another. Keep plugging away and you'll get it working. (Sorry it's not more helpful, but good luck)


Title: Re: Game Maker Help Thread!
Post by: Kegluneq on January 25, 2010, 04:50:09 PM
All the code for what items do when you press the action key is in scrUseItem.


Title: OK now,
Post by: banna8 on January 25, 2010, 05:50:52 PM
Got the floating to work mostly(sprite)
Got the lipstick kiss to work.
Now I get this:

Code:
ERROR in
action number 1
of  Step Event
for object oSpiderHang:

ERROR in
action number 1
of  Step Event
for object oBat:

Error in code at line 21:
   dist = point_distance(x+8, y+8, oPlayer1.x, oPlayer1.y)
                                            ^
at position 43: Unknown variable x


Error in code at line 17:
   else if (not collision_point(x, y-16, oSolid, 0, 0) or (dist < 90 and oCharacter.y > y and abs(oCharacter.x - (x+8)) < 8))
                                                                                    ^
at position 83: Unknown variable y

___________________________________________
ERROR in
action number 1
of  Step Event
for object oItem:

Error in code at line 41:
           if (oPlayer1.facing == LEFT) x = oPlayer1.x - 4; 
                        ^
at position 23: Unknown variable facing

Also, the kissing sound is spammed as if a step thing. (might be able to figure that out.) {FIXED}

but why the spiders!?!?!? I did nothing to the spiders!!!

EDIT: I think the annoying noise is coming from a sneaky kiss that spawns in the corner. I'll have to find it somewhere in the code.

EDITEDIT: found it!

EDITEDITEDIT: I feel as if I am taking all of the attention/energy of this thread. You think I should make like a NOOBISH I DON'T KNOW WHAT I'M DOING GIRL POWER MOD thread?

EDIT ^ 4: Look at me, solving my own problems! (one less bug)


Title: Re: Game Maker Help Thread!
Post by: Kegluneq on January 25, 2010, 07:38:05 PM
Yay! Don't worry about "hijacking" the thread. There is no such thing.
This thread was created for the sole purpose of people asking their questions, and having them answered.


Title: Cool
Post by: banna8 on January 25, 2010, 08:31:27 PM
At this point, I only see four bugs. (AWESOME!)

1) Lipstick doesnt dissapear upon use.

2) when I have > 1 bomb, I can't switch to lipstick.

3) when I switch to lipstick, I'm busted for "Theft"

4) i can duplicate items by switching to and from the lipstick.

Also, can I add lipstick to the... Misc. store perhaps, or would I need another store entirely?


Title: Re: Game Maker Help Thread!
Post by: Kegluneq on January 25, 2010, 09:30:35 PM
Those are some strange bugs...


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on January 25, 2010, 09:42:06 PM
lipstick might be fixed if you add cost = 0;


Title: Re: Game Maker Help Thread!
Post by: Arucard 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!


Title: Re: Game Maker Help Thread!
Post by: Kegluneq on January 26, 2010, 08:21:59 PM
I added a nice little table of contents to the first post.


Title: Re: Game Maker Help Thread!
Post by: Arucard on January 27, 2010, 06:44:40 AM
That's handy-dandy! Thanks Keg!  ;D
Edit: to avoid dreaded double-post :)

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  :-\)

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!  ;D (Also sorry this was such a humongous post!)


Title: Re: Game Maker Help Thread!
Post by: MagiMaster 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.)


Title: Thanks Arucard!
Post by: banna8 on January 27, 2010, 02:10:49 PM
I will be incorporating this in the next build.


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod 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?


Title: Re: Game Maker Help Thread!
Post by: Kegluneq on January 27, 2010, 06:09:28 PM
You'd probably have to edit explosions to not destroy ropes.


Title: Re: Game Maker Help Thread!
Post by: Arucard 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.


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod 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!


Title: Re: Game Maker Help Thread!
Post by: Arucard 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.


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod 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


Title: Re: Game Maker Help Thread!
Post by: Arucard on January 28, 2010, 03:54:58 AM
That's weird, it works fine in Vanilla Spelunky.  :(


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on January 28, 2010, 11:01:20 AM
That's weird, it works fine in Vanilla Spelunky.  :(
1)vannila spelunky?
2)... then what do I do?


Title: Re: Game Maker Help Thread!
Post by: Kirby on January 28, 2010, 12:14:10 PM
I can answer something!
Vanilla Spelunky is regular Spelunky with no mods.


Title: For Girl Power...
Post by: banna8 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.


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on January 28, 2010, 06:12:31 PM
Not really.

You would change the sprite of the bome shop (leave the name the same) and the edit what's in it, and what they say.


Title: Re: Game Maker Help Thread!
Post by: MagiMaster on January 28, 2010, 06:21:01 PM
The code for generating the signs is in scrRoomGen (2,3,4,...). The code for generating shop items is in scrShopItemsGen. Just change what these two do for bomb shops while playing the damsel.


Title: Re: Game Maker Help Thread!
Post by: Arucard on January 29, 2010, 07:28:58 AM
I actually uploaded and updated a couple tutorials on this to the Wiki yesterday, it's pretty easy, but if you want you could go there and check it out.  ;D It's under the Modifications/Mods section, you see it on the main page.


Title: Re: Game Maker Help Thread!
Post by: Sudonimus on February 05, 2010, 02:13:22 PM
I saw this thread was near the bottom of the page;
I didn't want to spam, but seeing as I need help;
How do you edit more than one sprite at once?


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on February 05, 2010, 02:56:22 PM
It depends how you wanna change them, but if you're changing color, I know that you could just change the color for the subheading of the sprite you are changing... if there is a subheading they are under....


Title: Re: Game Maker Help Thread!
Post by: Sudonimus on February 05, 2010, 08:18:32 PM
Subheading...?


Title: Re: Game Maker Help Thread!
Post by: Arucard on February 05, 2010, 08:41:42 PM
Are you talking about the animations? Like looking at the running sprite it has 6 or so subimages. If so, open the first when the pain-like program comes up there is an arrow toward the top-left of the window that will let you switch between the subimages. It's a lot easier to save the whole thing somewhere and work on it in your own image program though (like PSpro or GIMP), then load it into GM from wherever you saved it.


Title: Re: Game Maker Help Thread!
Post by: banna8 on February 10, 2010, 08:38:43 AM

In my mod, my wall-destrying lipstick doesn't destroy the material ontop of blocks. (grass, rubble) How can I make it so that it does?

EDIT: also, how can I make it so that custom variables can be changed in editor?
sounds confusing, but instead of changing starting bombs and rope, I want to change starting lipstick and gum in the editor.


Title: Re: Game Maker Help Thread!
Post by: DariusK on February 10, 2010, 09:06:24 AM
The black market entrance is an object called oXMarket, so just make sure your lipstick doesn't destroy any object of that type. You could even hack it and put in a check where if the lipstick collides with an oXMarket, set a variable called createXMarket = true, and then in the destroy code add a line saying

if (createXMarket) {make an oXMarket instance}

The black market entrance is placed in the script scrEntityGen, line 220 and line 313 (line 313 forces a market entrance to be created if for some reason we didn't create one when we were supposed to).

The code that triggers when you go into the black market entrance and head toward the black market is in oPlayer1 Step event,

Code:
    if (collision_point(x, y, oXMarket, 0, 0)) global.genBlackMarket = true;

Also, if you care, the code that makes the udjat blink is on line 1 of the oGame Step event:

Code:
if (not instance_exists(oXMarket)) global.udjatBlink = false;
else
{
    with oPlayer1
    {
        dm = distance_to_object(oXMarket);
        if (dm < 4) dm = 4;
        if (oGame.alarm[2] < 1 or dm < oGame.alarm[2]) oGame.alarm[2] = dm;
    }
}



Title: Re: Game Maker Help Thread!
Post by: hyperme on February 13, 2010, 07:31:43 AM
How would I pause the action and bring up a menu if a buton was pressed.
Also, how would I make text appear on a hover over?


Title: Re: Game Maker Help Thread!
Post by: MagiMaster on February 13, 2010, 09:02:54 AM
For hovering, the mouse enter and mouse leave events would probably be the best way to go, but the mouse_x and mouse_y variables could also be used.

For the menus, you should look up what happens when the user presses ESC.


Title: Re: Game Maker Help Thread!
Post by: banna8 on February 14, 2010, 01:02:35 PM
Ok, I'm trying to make a sprite change with your favor. Right now, I have this:

Code:
image_index = global.favor/2

In the step event. This might work if I change the number 2 to something else, but I need to know if favor has min/max caps. If it does, and I knew what they were, this would be much easier.


Title: Re: Game Maker Help Thread!
Post by: hyperme on February 14, 2010, 01:57:00 PM
Where's the code for pressing ESC?


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on February 14, 2010, 03:37:37 PM
keyboard_check_pressed(vk_escape)

is that what you mean?


Title: Re: Game Maker Help Thread!
Post by: Kegluneq on February 14, 2010, 11:21:28 PM
Ok, I'm trying to make a sprite change with your favor. Right now, I have this:

Code:
image_index = global.favor/2

In the step event. This might work if I change the number 2 to something else, but I need to know if favor has min/max caps. If it does, and I knew what they were, this would be much easier.
Nope. I don't believe favor is ever limited.
You could easily make it so though.


Title: Re: Game Maker Help Thread!
Post by: banna8 on February 15, 2010, 04:00:38 PM
ok, I got the favor sprite working now, and I added it to the lighting part of oscreen like this:

Code:
with oSoul
            {
                draw_circle((x+8)-view_xview[0], (y+8)-view_yview[0], 32 - global.favor, false);
            }

Now I want the color to be determined as well. Light blue if favor is negative, red if positive. How would I go about doing this?

Also, where is the script that effects the room feelings and their rarity? I saw it before...


Title: Re: Game Maker Help Thread!
Post by: Kegluneq on February 15, 2010, 05:48:45 PM
I believe its in the level generation scripts.
And GM should have some built-in color changing functions, search the GM help file.


Title: Re: Game Maker Help Thread!
Post by: ipwnu1337 on February 15, 2010, 06:32:45 PM
Question:  Is there a way to make it so that an object creates a sphere of darkness around it?


Title: Re: Game Maker Help Thread!
Post by: banna8 on February 15, 2010, 06:55:08 PM
You could make a semitransparent sprite, yes.


Title: Re: Game Maker Help Thread!
Post by: Kegluneq on February 15, 2010, 08:34:23 PM
Question:  Is there a way to make it so that an object creates a sphere of darkness around it?
Ask MGG about the particle effects.


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on February 15, 2010, 08:54:02 PM
Huh? oh yeah that could work. You want my kinda of aura? I thought the sprite would work fine... I just used drag and drop...


Title: Re: Game Maker Help Thread!
Post by: ipwnu1337 on February 15, 2010, 09:42:20 PM
I meant dark, as in a dark level, but I guess that works too.  w/e.


Title: Re: Game Maker Help Thread!
Post by: DariusK on February 16, 2010, 09:46:04 AM
You'll want to mess around with the darkness drawing code that I talk about here:

http://mossmouth.com/forums/index.php?topic=586.msg17312#msg17312

The thing is the darkness code only runs when it's a dark level, so you'll want to make sure that whatever you write works in a non-dark level too.

But I'm intrigued by the problem -- I might try and do a short tutorial about making a darkness-generating object.


Title: Re: Game Maker Help Thread!
Post by: banna8 on February 16, 2010, 08:02:14 PM
Aggh! If only I could find things...

Where are player acceleration, max speed, jump height, and gravity controlled?

Thanks in advance! (if only the source had a map...)


Title: Re: Game Maker Help Thread!
Post by: DariusK on February 16, 2010, 08:06:53 PM
It's all in a script called characterCreateEvent. Fortunately it's all very well commented! Here's a snippet so you know what to look for.

Code:
xVelLimit = 16;            // limits the xVel: default 15
yVelLimit = 10;            // limits the yVel
xAccLimit = 9;             // limits the xAcc
yAccLimit = 6;             // limits the yAcc
runAcc = 3;                // the running acceleration

initialJumpAcc = -2;       // relates to how high the character will jump
jumpTimeTotal = 10;        // how long the user must hold the jump button to get the maximum jump height

climbAcc = 0.6;            // how fast the character will climb
climbAnimSpeed = 0.4;      // relates to how fast the climbing animation should go
departLadderXVel = 4;      // how fast character should be moving horizontally when he leaves the ladder
departLadderYVel = -4;     // how fast the character should be moving vertically when he leaves the ladder

Etc, etc.


Title: Re: Game Maker Help Thread!
Post by: banna8 on February 16, 2010, 08:14:45 PM
Thanks alot! This will be very helpful!


Title: Re: Game Maker Help Thread!
Post by: idoru on February 17, 2010, 12:33:49 PM
Thanks in advance! (if only the source had a map...)

No map, but it does have a sort of index. You can search for terms in scripts via Scripts > Search in Scripts. For code within objects, you can go to Edit > Show Object Information (at which point the program will likely hang while everything is parsed), save the results as a text file and then search that.


Title: Re: Game Maker Help Thread!
Post by: banna8 on February 17, 2010, 04:53:33 PM
Thanks. Now I have 2 more questions though.

1) I put this code in the collision with {myweapon} event for oEnemy:

Code:
hp -= other.damage;
countsAsKill = true;
playSound(global.sndHit);

if (global.favor < 0)
{
    if (oPlayer1.facing = RIGHT)
    {
        xVel = 1.5 * -global.favor
    }
    else if (oPlayer1.facing = LEFT)
    {
        xVel = 1.5 * global.favor
    }
}
else if (global.favor > 0)
{
if (bloodLeft > 0)
{
    scrCreateBlood(x+sprite_width/2, y+sprite_height/2, 1);
    if (hp < 0) bloodLeft -= 1;
}
}

The enemy gets hurt properly occording to favor when it is above 0, Enemies aren't affected when favor = 0. Both of those things are good.
However, the enemy will not fly in either direction, even when favor is all the way down to -32!

2) For the life of me, I can not find this. Where are the objests that sit on the surface of blocks? (grass,gravel) I can't find them as an object or a script.



Title: Re: Game Maker Help Thread!
Post by: Kirby on February 17, 2010, 05:20:25 PM
I can answer 2. It's under Backgrounds. It's called bgCaveTop, bgCaveTop2, bgCaveTop3, and bgCaveTop4.


Title: Re: Game Maker Help Thread!
Post by: Kegluneq on February 17, 2010, 08:37:27 PM
Hrm.
I can't figure out why it won't work, but the logic your using isn't that great. Instead of the enemy fly direction being based on player direction, it should be based on weapons position at the time of collision.
Unless this is some special weapon that behaves differently from normal projectiles?


Title: Re: Game Maker Help Thread!
Post by: banna8 on February 17, 2010, 08:41:10 PM
Sorry, its a melee weapon. Works exactly like a whip. (Its the flower from my mod if you need to know exactly)


Title: Re: Game Maker Help Thread!
Post by: Kegluneq on February 17, 2010, 08:42:53 PM
I see.

Have you looked at the yeti code yet?
The part where the yeti jumps back when you whip it may be what you need.


Title: Wow.....
Post by: banna8 on February 17, 2010, 08:53:11 PM
That worked. Just worked. No trial. No error. Thanks a bunch! New version's going up!


Title: Re: Game Maker Help Thread!
Post by: Kegluneq on February 17, 2010, 09:07:51 PM
Glad to be of some assistance!


Title: Re: Game Maker Help Thread!
Post by: halibabica on February 18, 2010, 05:55:28 PM
Okay, I'm having just a slight problem here.

I'm trying to make it so that when the player dies in my ManTrap mod, they burst into a pile of leaves instead of what usually happens.  And I got the leaves to work, but the problem is...they don't stop coming.  An endless number of leaves continue spewing out of wherever the player's corpse would have been.  Is there anything I can do to make them stop?  It's not game-breaking or anything, but it does look really stupid.


Title: Re: Game Maker Help Thread!
Post by: DariusK on February 18, 2010, 05:59:26 PM
You need to do something with the Animation End event. If what you're doing is doing an instance_destroy() to the player and then replacing it with an object that animates the leaves going everywhere, then just putting instance_destroy() in Animation End in your oLeavesExplode object would do the trick.


Title: Re: Game Maker Help Thread!
Post by: Kegluneq on February 18, 2010, 06:03:29 PM
Ah shoot Darius beat me to it. I was gonna suggest the same thing.


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on February 18, 2010, 06:08:02 PM
Um... anyone got an idea how to make it so when you hold an item, all explosions are safe and don't throw the safety item out of your hand?


Title: Re: Game Maker Help Thread!
Post by: halibabica on February 18, 2010, 06:13:04 PM
Well, that sounds like a good idea, but I already know it won't work because of a few things.

For starters, using instance_destroy on the player object causes the game to stop.  It doesn't crash, it doesn't freeze, it just stops.  You have to alt+F4 out of it.

Secondly, the 'leaf explode' I'm using is just the object 'oLeaf' spawned three times over where the player's corpse would be.  It worked just fine with the Ghost, but it has its own special conditions for ending the player's existence.

Ghost Chef's Recipe for Murder:
Code:
if (other.invincible == 0)
{
    if (true)
    {
        if (isRealLevel()) global.enemyDeaths[23] += 1;
        repeat(3)   {obj = instance_create(other.x+rand(-8,8), other.y+rand(-8,8), oLeaf);
                    if (global.isTunnelMan)
                    { obj.sprite_index = sLeafT;}
                    else if (global.isDamsel)
                    { obj.sprite_index = sLeafD;}}
        other.visible = false;
        other.invincible = 9999;
        other.bounced = true;
        global.plife = -99;
        playSound(global.sndHit);
        global.drawHUD = false;

But the code I'm looking at is here, in its current state:
Code:
if (dead) repeat(3) {obj = instance_create(x+rand(-8,8), y+rand(-8,8), oLeaf);
            obj.sprite_index = sLeafD;}

I need to add back in the 'visible = false' to make the player's corpse disappear.  But like I said, using instance_destroy on the player simply doesn't work.  oLeaf destroys itself when it hits the ground, but I have no clue how to make them stop coming.


Title: Re: Game Maker Help Thread!
Post by: DariusK on February 18, 2010, 06:16:51 PM
In oExplosion there's a Collide oItem event. In that code you see this:

Code:
if (other.held)
{
    with oPlayer1
    {
        holdItem = 0;
        pickupItemType = "";
    }
    other.held = false;
}

Change it to this:

Code:
if (other.held)
{
    with oPlayer1
    {
        if(holdItem.type != WHATEVERITIS)
        {holdItem = 0;
        pickupItemType = "";}
    }
    other.held = false;
}

That will make it so the item of WHATEVERITIS type doesn't fly out.

To make yourself invincible to explosions, go here in the Step event of oPlayer1:

Code:
if (collision_rectangle(x-8, y-8, x+8, y+8, oExplosion, 0, 0))
{
    global.plife -= 10;
    if (global.plife > 0 and isRealLevel()) global.miscDeaths[1] += 1;
    explosion = instance_nearest(x, y, oExplosion)
    if (explosion.x < x) xVel = rand(4,6);
    else xVel = -rand(4,6);
    yVel = -6;
    burning = 50;
    stunned = true;
    stunTimer = 100;
       
    scrCreateBlood(x, y, 1);
}

To the IF statement just add "and holdItem.type != WHATEVERITIS". That will only run the explosion-hurting code if you're not holding that item.


Title: Re: Game Maker Help Thread!
Post by: Kegluneq on February 18, 2010, 06:17:55 PM
@halibabica:
Oh I see what's going on. I assume this is in the step event?
Its checking at every step, and at every step it sees that your dead and makes leaves.

One way to fix this, would be to simply replace the blood with leaves, and add a bloodLeft variable (like the other humanoids) if there isn't one already.


Title: Re: Game Maker Help Thread!
Post by: halibabica on February 18, 2010, 06:19:52 PM
Wouldn't replacing blood make everyone bleed leaves?


Title: Re: Game Maker Help Thread!
Post by: Kegluneq on February 18, 2010, 06:20:46 PM
I mean replacing everywhere in the code oPlayer1 calls for blood so that it calls for leaves instead.
Not replacing the oBlood object itself.


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on February 18, 2010, 06:21:14 PM
Wouldn't replacing blood make everyone bleed leaves?
Yes, yes it would.

DariusK the man thing I get, is that it doesn't seem to think that
        if(holdItem.type != Demon) is true no matter...

never mind I just figured it out.


Title: Re: Game Maker Help Thread!
Post by: halibabica on February 18, 2010, 06:24:21 PM
I mean replacing everywhere in the code oPlayer1 calls for blood so that it calls for leaves instead.
Not replacing the oBlood object itself.
Problem: the point at which the player dies doesn't always result in blood appearing.  There's no reference to the blood script at that point.

But I have an idea based on your suggestion.  If I make a leaves_left variable that only decreases when the player object is (dead), could I limit the leaves that appear that way?  And where should I place that variable for its initial creation?


Title: Re: Game Maker Help Thread!
Post by: Kegluneq on February 18, 2010, 06:40:11 PM
Then make it so that blood always appears when you die, it's not that difficult.
Put new variables in the script under the create event.


Title: Re: Game Maker Help Thread!
Post by: halibabica on February 19, 2010, 08:34:44 AM
Ah, I got it to work!  I added the line 'leavesleft = 3' to oPlayer's Create event and had the variable reduced by 1 for every leaf it created upon death.  Works like a charm!

So now I only need to tweak a few more things.  I could have the next release ready tonight.  Thanks, everybody!


EDIT: Okay, now I have new problems!
I'm starting to implement the Bites into the mod, and so far I have it so you can eat an enemy you're carrying.  But there are two things I'm not sure how to do:

1. I need to make it so you can't move while eating.  I made it so you have to be standing still to start with, but you can still move after the eating animation begins.

2. I need to slow down the image speed of the eating animation.  It happens really fast at the moment, and putting 'image_speed = x' before it didn't help.

That's all for now, though I'm sure I'll have all kinds of problems later.  ;)


Title: Re: Game Maker Help Thread!
Post by: DariusK on February 19, 2010, 08:52:27 AM
1: You'll want to create a variable on the player object called isEating or something like that, which is set to true when you start the eating animation and set to false when you're done. Then include that variable in an IF statement in the player step event where you set xVel = 0 and yVel = 0, that should hold you in place. Maybe.

2: image_speed is interesting. It's mostly set in the script called characterStepEvent. Here's an example where the image_speed is actually calculated from the speed of the character:

Code:
//calculates the image_speed based on the character's velocity
if (state == RUNNING or state == DUCKING or state == LOOKING_UP)
{
    if (state == RUNNING or state == LOOKING_UP) image_speed = abs(xVel) * runAnimSpeed + 0.1;
}

if (state == CLIMBING) image_speed = sqrt(sqr(abs(xVel))+sqr(abs(yVel))) * climbAnimSpeed
if (xVel >= 4 or xVel <= -4)
{
    image_speed = 1;
    if (platformCharacterIs(ON_GROUND)) setCollisionBounds(-8, -8, 8, 8);
    else setCollisionBounds(-5, -8, 5, 8);
}
else setCollisionBounds(-5, -8, 5, 8);
if (whipping) image_speed = 1;
if (state == DUCKTOHANG)
{
    image_index = 0;
    image_speed = 0.8;
}
//limit the image_speed at 1 so the animation always looks good
if (image_speed > 1) image_speed = 1;

The big issue here is one of STATE. What's happening is even while you're eating, you're probably in the RUNNING state so it will calculate the image_speed as above and overwrite whatever speed you put in. What you probably need to do (instead of creating the isEating variable) is to create a new state for the player, called EATING.  You'd do that in the characterCreateEvent script:

Code:
//constant states that the platform character may be
STANDING = 10;
RUNNING = 11;
DUCKING = 12;
LOOKING_UP = 13;
CLIMBING = 14;
JUMPING = 15;
FALLING = 16;
DYING = 17;
LEFT = 18;
RIGHT = 19;
ON_GROUND = 20;
IN_AIR = 21;
ON_LADDER = 22;
HANGING = 23;
DUCKTOHANG = 24;
// NEW LINE HERE, I'm picking 30 because I'm not sure if there are maybe some other states buried in the code
EATING = 30;

Then, when eating starts, change the player's state to "state = EATING;" and when it ends, switch it back to I guess STANDING or RUNNING. In characterStepEvent you'd add some code to say if the state is EATING, image_speed = whatever.


Title: Re: Game Maker Help Thread!
Post by: halibabica on February 19, 2010, 09:04:20 AM
Heheh, I had actually already added the state 'EATING' to the player states, so at least I'm doing something right!  ;D

1: I tried adding an IF statement for state == EATING to the player's step event with xVel = 0, but it didn't stop it from being able to move.  yVel isn't an issue because I already set it to 'can'tjump' like with the Mattock.  Could something like 'can'tjump' be made and used for horizontal movement instead?

2: worked perfectly!  Thank you!


Title: Re: Game Maker Help Thread!
Post by: DariusK on February 19, 2010, 09:05:45 AM
Wow, I'm glad the state thing just worked out for you. I would've bet I missed something :D


Title: Re: Game Maker Help Thread!
Post by: halibabica on February 19, 2010, 09:11:42 AM
 ;D ;D ;D

I just solved my other problem, too!  I changed the conditions of the characterStepEvent under 'if (stunned or dead)' to be 'if (stunned or dead or state = EATING)'.  Now the player remains stuck in place until the animation finishes.  Thanks anyway, though!


Title: Re: Game Maker Help Thread!
Post by: DariusK on February 19, 2010, 09:13:14 AM
...and that's the power of states.

I should maybe do a tutorial on adding a new state to the character, and talk a little bit about why states are powerful and way better for some things than local is_whatever variables.


Title: Re: Game Maker Help Thread!
Post by: halibabica on February 19, 2010, 01:00:36 PM
I have yet another new problem!

So, I've got Bites working and all the variables and animations and states involved are just GREAT.  But now I'm trying to fix it so if something interrupts the player eating (such as a Yeti throwing them), the object they were eating returns to normal.  I've got the whole thing down to just one detail: visibility.  When the player tries to eat the object, I have to set its visibility to false so it isn't holding it and eating it at the same time.  But if the player gets interrupted while eating, I can't get the item to become visible again.  Any suggestions?


Title: Re: Game Maker Help Thread!
Post by: DariusK on February 19, 2010, 01:03:09 PM
Try this in the player object when he gets hit with something:

obj = instance_nearest(x,y,oItem);
obj.visible = true;


Title: Re: Game Maker Help Thread!
Post by: halibabica on February 19, 2010, 02:18:09 PM
;D

It worked!  Not exactly what you suggested, but I got it to work!

Trouble was, it wasn't an oItem that was getting eaten, but an oEnemy.  With another enemy so close by, it couldn't set the visibility correctly.  But that gave me an idea, so I added this line into the Eating event:

'LostLunch = holdItem'

...because the game needed a variable to attach to the object between events.  Then I added this to the interruption event:

'LostLunch.visible = true;'

And it worked exactly like it should.  Thanks for your help, even if it was indirect! :D


MORE PROBLEMS!  :-X

Okay, now I'm making the event for an item to be eaten, but I'm using one generic animation for all potential items.  What I need is for the item being eaten to become invisible partway through the player's eating animation.  I think image_index can do something like that, but everything I've tried so far has failed.


Title: Re: Game Maker Help Thread!
Post by: DariusK on February 19, 2010, 02:21:52 PM
Weird, I would imagine something in the Step event like

with (oThingThatsAnimating) if (image_index == [# of the frame where you want it invisible]) { item = (code to return the objectID of the item -- maybe oPlayer1.heldItem)
item.visible = false;
}


Title: Re: Game Maker Help Thread!
Post by: banna8 on February 19, 2010, 02:25:51 PM
You'll probably want something like this:

Quote
if (image_index > [whatever part of the animation you want the item to become invisible])
{
image_alpha = 0
}

EDIT: ninja'd


Title: Re: Game Maker Help Thread!
Post by: halibabica on February 19, 2010, 02:54:18 PM
@banna: ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D ;D

It was the greater than symbol that did it!  THANK YOU!!!


Title: Re: Game Maker Help Thread!
Post by: banna8 on February 21, 2010, 01:08:32 PM
Okay, why isnt this working?


Code:
if (instance_number(oPlayer1) == 1)
{
    x = oPlayer1.x
    y = oPlayer1.y
   
    if (global.side == -1)
{
    if (global.bad == 1)
    {
        if (oPlayer1.facing == LEFT)
        {
            image_index = 3
        }
        else
        {
            image_index = 4
        }
    }
    else if (global.good == 1)
    {
        if (oPlayer1.facing == LEFT)
        {
            image_index = 1
        }
        else
        {
            image_index = 2
        }
    }
}

if not (global.side == -1)
    {
        image_index = 5
    }
}
else if (instance_number(oPDummy) == 1)
{
    x = oPDummy.x
    y = oPDummy.y
   
    if (global.side == -1)
{
        if (global.bad == 1)
    {
        if (oPDummy.facing == LEFT)
        {
            image_index = 3
        }
        else
        {
            image_index = 4
        }
    }
    else if (global.good == 1)
    {
        if (oPDummy.facing == LEFT)
        {
            image_index = 1
        }
        else
        {
            image_index = 2
        }
    }
    }
   
    if not (global.side == -1)
    {
        image_index = 5
    }   
}
else
{
instance_destroy()
}


This goes into a step event for "wings"
They don't allow me to fly,(they shouldn't) but they should changes sprites to indicate my wing type. When side == -1, I can fly.
Sprite indexes are as follows:
1 = good left
2 = good right
3 = bad left
4 = bad right
5 = blank

At this point, it is always showing the good left sprite (image_index = 1)
Why is this happening?

Also, I was thinking of adding a world. How would I go about doing that?


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on February 22, 2010, 12:37:16 PM
just a guess, but It might have something to do with useing oPDummy and not 0Player1.


Title: Re: Game Maker Help Thread!
Post by: banna8 on February 22, 2010, 09:00:48 PM
As you might see, there is first a check for oPlayer1, then a check for oPDummy. (This is so the object can also be used in transitions) either way, I was wondering how I could check for states. (especially LEFT and RIGHT). when I use:

Code:
if (oPlayer1.status == LEFT)

I get this error:

Code:
___________________________________________
ERROR in
action number 1
of  Step Event
for object oWings:

Error in code at line 21:
           if (oPlayer1.status == LEFT)
                        ^
at position 23: Unknown variable status

what's wrong? thats how npc's do it.


Title: Re: Game Maker Help Thread!
Post by: DariusK on February 22, 2010, 09:17:13 PM
Did you make sure to declare the variable in the oPlayer1 Create event? Just a simple

status = LEFT;

would do the trick. (I make that mistake all the time, declaring a variable inside a regular event and then try to externally reference it. The only externally available variables are the ones declared in Create.


Title: Re: Game Maker Help Thread!
Post by: banna8 on February 22, 2010, 10:28:31 PM
You know, I tried this, but it didn't work. I thought this was strange, and I thought there was already a direction check integrated into spelunky. ( the states are established in scrCharacterCheateEvent)


Title: Re: Game Maker Help Thread!
Post by: Arucard on February 23, 2010, 12:53:31 PM
I think for that you're supposed to use if (facing == LEFT). If the code is in a step event for an object, try adding with (oPlayer1) to the top of the block you want to affect the player.


Title: Re: Game Maker Help Thread!
Post by: banna8 on February 24, 2010, 07:38:23 AM
Quote
try adding with (oPlayer1)

That did it! thanks!

Now I have something else. I want to create an NPC that you can pick up at all times.(even when not stunned or dead)

So far I've tried copying all the events of oEnemy to my NPC and making its parent oItem, but that didnt work, as a lot of the variables werent established.

Also, I don't want the NPC to hurt the player as a normal enemy would, if that matters.



Title: Re: Game Maker Help Thread!
Post by: MagiMaster on February 24, 2010, 09:16:06 AM
Do they need to move around? Otherwise it might be easier to just treat them as items.


Title: Re: Game Maker Help Thread!
Post by: banna8 on February 24, 2010, 09:34:57 AM
Yes they do, the hop around like a frog or zombie. I have made it so that they don't hurt the player fine, and they do pretty much everything I wanted, but they still are un-pickable-upable (definately not a word)


Title: Re: Game Maker Help Thread!
Post by: halibabica on February 24, 2010, 04:33:03 PM
I have a new problem!  :(

I'm working on making Shopkeepers hostile toward the player by causing them to attack when the player gets too close to them.  I already figured out how to make that work, but the problem is I only want them to attack if the player is inside their shop.  So the player could get close from above/below/behind the shop, but if they venture too far inside, the shopkeep starts firing.  I thought the isInShop script could help, but everything I've tried with it has failed.  Anybody know how the game can tell when the player's in a shop?

As a small note, I'm including this script in the Shopkeeper's Step Event.  Would it work better somewhere else?


Nevermind, I found a smoke 'n mirrors way around the problem.  Shopkeeps will now only attack you if you approach them in their stores.  They give you fair warning, too!


Title: Re: Game Maker Help Thread!
Post by: Sudonimus on February 24, 2010, 08:32:24 PM
Ugh. I'm getting nowhere.
I need to make an item that, when 6 collected, lets you gain a life.


Title: Re: Game Maker Help Thread!
Post by: Kegluneq on February 24, 2010, 08:36:32 PM
Make a variable that represents how many you've picked up so far
ie: global.mushrooms = 0

Once that number hits 6, have it do its thing and reset the counter back to zero.


Title: Re: Game Maker Help Thread!
Post by: Sudonimus on February 24, 2010, 08:41:56 PM
Oh. So far I did
Create Event:
Code:
mushroomCount = 6;
Without knowing anything.


Title: Re: Game Maker Help Thread!
Post by: Arucard on February 25, 2010, 12:27:13 PM
In the player's create event, or the mushrooms?


Title: Re: Game Maker Help Thread!
Post by: halibabica on February 25, 2010, 03:14:35 PM
I have a small problem, but it's got me completely stumped.  How do you tell the game to make a sprite face the opposite direction (ie inverted)?  In the instances I've seen where it happens, all that's put is a line of code saying 'facing = [DIRECTION]' which doesn't do anything on its own.  Can somebody clue me in?


Title: Re: Game Maker Help Thread!
Post by: ipwnu1337 on February 25, 2010, 06:05:56 PM
By the way, how do you change the text in the intro?  I've never found out how to do that.

[EDIT]  Oh, wait just found out how.  Nevermind.


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on February 25, 2010, 08:36:34 PM
I have a small problem, but it's got me completely stumped.  How do you tell the game to make a sprite face the opposite direction (ie inverted)?  In the instances I've seen where it happens, all that's put is a line of code saying 'facing = [DIRECTION]' which doesn't do anything on its own.  Can somebody clue me in?
where the sprite would be changed
if facing ="left"
change sprite to left sprite
else
change sprite to right sprite.


Title: Re: Game Maker Help Thread!
Post by: banna8 on February 25, 2010, 09:00:23 PM
Okay, if the mushroom problem hasn't been soved yet, here it is...

In scrClearGlobals:
add

Code:
global.Mushrooms = 0

In scrHoldItem :
add

Code:
if (itemType == "Mushroom")
{
     with (oMushroom)
     {
          if (global.Mushrooms > 4)
          {
               global.plife += 1
               global.Mushrooms = 0
          }
          global.Mushrooms += 1
          instance_destroy()
     }
}


Also, I have a request of my own. Is it possible to draw a gradient rectangle (as you see in the drag and drop DRAW section) using GML?

I want to draw a gradient on the HUD using scrDrawHUD


Title: Re: Game Maker Help Thread!
Post by: halibabica on February 25, 2010, 09:50:32 PM
where the sprite would be changed
if facing ="left"
change sprite to left sprite
else
change sprite to right sprite.
But the game doesn't use both left and right sprites.  The right-facing sprites are the same as the left, but flipped on their x axis.  I don't know how to tell the game to flip them and I'm not sure how Derek pulled it off.


Title: Re: Game Maker Help Thread!
Post by: Kegluneq on February 25, 2010, 11:12:44 PM
@mushrooms:

I don't think scrHoldItem is the right place to put that.
Look for where pick-up code for items like gloves and spring shoes are and model after those.


Title: Re: Game Maker Help Thread!
Post by: MagiMaster on February 26, 2010, 06:26:57 AM
@halibabica, I think it uses an x-scaling of -1 to flip the images. You'll have to dig around in the code to see how exactly that's done though. (Look for the variable image_xscale.)

@banna8, I used the scrStealItem script to implement eating the mushrooms in my mod. Look around in there for the other items that go off immediately and copy that.


Title: Question
Post by: banna8 on February 26, 2010, 01:10:09 PM
If I were to resprite a block and its mask to be a 45 degree angle right triangle, would it work in spelunky?


Title: Re: Game Maker Help Thread!
Post by: DariusK on February 26, 2010, 01:14:43 PM
No, I am almost positive that the platform engine it uses doesn't work that way. The engine DOES support curved/sloped surfaces but I am fairly certain it's not based on the mask of the sprite.


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on February 26, 2010, 01:58:47 PM
How do you turn the game upside down?


Title: Re: Game Maker Help Thread!
Post by: DariusK on February 26, 2010, 02:02:25 PM
The game is rendered to what's called a "surface" in Game Maker. The surface is drawn to the screen using a draw function -- you can literally warp the whole game screen by changing how the surface is drawn. (This is how the 1x 2x 3x 4x draw scale works in the configuration.) Drawing the screen upside down would just involve doing a draw_surface_ext() call in the right place with a yScale of -1 (which keep the scale the same but does a flip over the x-axis).


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on February 26, 2010, 02:52:14 PM
Uhh.... so how do you make it so that when you press a button (Perhaps "U"), the game turns upside down?


Title: Re: Game Maker Help Thread!
Post by: Kegluneq on February 26, 2010, 03:14:56 PM
go into the big oGame object, and create a keyboard event for 'U' that does the draw_surface thingy DK was talking about.


Title: Re: Game Maker Help Thread!
Post by: DariusK on February 26, 2010, 03:16:36 PM
Here, I did it for you.

Go into oScreen in the Begin Step event, and at the bottom replace this line:
    
Code:
draw_surface_stretched(screen,screen_x,screen_y,screen_w*screen_scale,screen_h*screen_scale);

With this line:    

Code:
draw_surface_ext(screen,screen_x,screen_y+(240*screen_scale),screen_scale,screen_scale*-1,0,c_white,1);

I'll leave it to you to bind that to a keyboard input. Also, as is it doesn't cover pausing the game or dark levels (I think).


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on February 26, 2010, 03:31:55 PM
Thank you!  I'm putting this in one of my mods


Title: Re: Game Maker Help Thread!
Post by: halibabica on February 26, 2010, 04:26:23 PM
...with a yScale of -1 (which keep the scale the same but does a flip over the x-axis).
Ah, this!

@halibabica, I think it uses an x-scaling of -1 to flip the images. You'll have to dig around in the code to see how exactly that's done though. (Look for the variable image_xscale.)
And this!  Very likely these are the root of my problem.  Thank you very much; I'll run some experiments with this info.


Title: Re: Game Maker Help Thread!
Post by: ipwnu1337 on February 26, 2010, 04:44:15 PM
How do you change what the message signs say in the tutorial?  I've gotten around to changing the level itself but I don't know how to change the text on message signs.


Title: Re: Game Maker Help Thread!
Post by: Sudonimus on February 26, 2010, 05:36:15 PM
I remember seeing that.
Isn't there those quotation marks with the words in it?


Title: Re: Game Maker Help Thread!
Post by: halibabica on February 26, 2010, 05:37:23 PM
How do you change what the message signs say in the tutorial?  I've gotten around to changing the level itself but I don't know how to change the text on message signs.
You have to edit the object "oMsgSign" in the Blocks folder.  It has all the messages for the signs in the tutorial cave.  You can also add and remove signs, but you have to set their coordinates and whatnot.


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on February 26, 2010, 07:01:08 PM
I'm gonna ask a LOT of questions for the Vamp mod.....

Basically, imagine a person using Game Maker for the first time in their life trying to make it, that's me

EDIT: How do I make the player jump higher?


Title: Re: Game Maker Help Thread!
Post by: Sudonimus on February 26, 2010, 07:07:53 PM
...Looking now.


Title: Re: Game Maker Help Thread!
Post by: Kirby on February 26, 2010, 07:14:33 PM
How do I change the starting messages?


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on February 26, 2010, 07:17:03 PM
characterCreateEvent

change this:
initialJumpAcc = -2;       // relates to how high the character will jump
jumpTimeTotal = 10;        // how long the user must hold the jump button to get the maximum jump height


to this:

initialJumpAcc = -2.5;       // relates to how high the character will jump
jumpTimeTotal = 15;        // how long the user must hold the jump button to get the maximum jump height

Which starting messege? the random ones? edit oIntro


Title: Re: Game Maker Help Thread!
Post by: Sudonimus on February 26, 2010, 07:36:00 PM
@Kirby:
Go to oTitle.
And it's in the Draw Event.
It's really fun changing them around.


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on February 26, 2010, 08:20:09 PM
canRun = 1;                // when the user presses the shift button, should the character be allowed to run?
canFly = 0;                // whether the character can do a fly jump when running at full speed
canFlyJump = 0;            // whether the character can do continuous fly jumps (mid-air)
flyMaxJumps = 5;           // the maximum number of jumps the character can perform while flying


How come when I change this, it doesnt do anything?

Oh yea, this is in characterCreateEvent

And how do I  make it so that the sprite changes when I fly jump?


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on February 26, 2010, 08:43:53 PM
canRun = 1;                // when the user presses the shift button, should the character be allowed to run?
canFly = 0;                // whether the character can do a fly jump when running at full speed
canFlyJump = 0;            // whether the character can do continuous fly jumps (mid-air)
flyMaxJumps = 5;           // the maximum number of jumps the character can perform while flying


How come when I change this, it doesnt do anything?

Oh yea, this is in characterCreateEvent

And how do I  make it so that the sprite changes when I fly jump?
He doesn't use that I think, but I am not sure. And you would go to where all sprites are and use if STATE (or whatever it is) = "fly"
If facing = left
 sprite = left fly
if facing = right
sprite =right fly


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on February 26, 2010, 08:46:47 PM
I know, but if I change the 0's they still dont work


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on February 26, 2010, 09:29:38 PM
Ask the guy that did morality mod, he got flying working.


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on February 27, 2010, 10:16:04 AM
I need the jetpack effect and the cape effect too

What I need
-Flying (like jetpack)
-Cape (pressing x slows down fall but there is no real cape)
-Longer distance for falling damage/No falling damage

EDIT: No, nevermind, now all I need is this
-Longer distance for falling damage/No falling damage


Title: Re: Game Maker Help Thread!
Post by: Kirby on February 27, 2010, 12:52:22 PM
Where do I adjust the percentage of dark levels?


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on February 27, 2010, 01:13:47 PM
in clear globals

global.probDarkLevel = 12; // 12

change that.


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on February 27, 2010, 01:25:48 PM
How do I change the distance for falling damage?

How do I make it so that the sprite changes when I do an action? (when I double jump)


Title: Re: Game Maker Help Thread!
Post by: Kirby on February 27, 2010, 02:17:18 PM
Any idea on how I might re-add flares into the game? Like they were originally.


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on February 27, 2010, 02:20:17 PM
How were they originally?  And what do you mean re-add?

And can you stop posting questions on top of my questions?  This is the second time!

How do I change the distance for falling damage?

How do I make it so that the sprite changes when I do an action? (when I double jump)


Title: Re: Game Maker Help Thread!
Post by: Kirby on February 27, 2010, 02:27:13 PM
I didn't realize you were the guy who needed ALL his questions answered IMMEDIATELY. Or that NOBODY else can post questions. I'm sorry.

Also originally they didn't appear at entrance to dark levels, you started the game with a limited amount of them, like bombs.


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on February 27, 2010, 02:28:19 PM
Oh, I didn't know that........ and I didn't mean it like that, sorry Kirby :-\


Title: Re: Game Maker Help Thread!
Post by: Kirby on February 27, 2010, 02:30:27 PM
Sorry for getting angry, I am just in a bad mood because I'm sick today. -_-'


Title: Re: Game Maker Help Thread!
Post by: banna8 on February 27, 2010, 02:33:38 PM
Quote
Also, I have a request of my own. Is it possible to draw a gradient rectangle (as you see in the drag and drop DRAW section) using GML?

I want to draw a gradient on the HUD using scrDrawHUD

Has anyone any insight as far as this?


Title: Re: Game Maker Help Thread!
Post by: DariusK on February 27, 2010, 02:41:17 PM
You can draw a gradient rectangle using the draw_rectangle_color() function. From the Game Maker help files:

draw_rectangle_color(x1,y1,x2,y2,col1,col2,col3,col4,outline) Draws a rectangle. The four colors indicated the colors at the top-left, top-right, bottom-right, and bottom-left vertex. outline indicates whether only the outline must be drawn (true) or it should be filled (false).


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on February 27, 2010, 02:44:54 PM
Darius, can you answer this?

How do I make it so that the sprite changes when I do an action? (when I double jump/fly)


Title: Re: Game Maker Help Thread!
Post by: DariusK on February 27, 2010, 02:51:16 PM
All you need to do is change sprite_index when the action occurs. Just set it equal to the name of the new sprite you want it switched to.

Code:
sprite_index = sYourNewSprite;


Title: Re: Game Maker Help Thread!
Post by: banna8 on February 27, 2010, 02:52:18 PM
try :

Code:
if (kJumpPressed)
{
     sprite_index = [{FLYING SPRITE}]
}

EDIT: NINJA'D!!!


Title: Re: Game Maker Help Thread!
Post by: Kirby on February 27, 2010, 02:52:28 PM
How would I add flares to the HUD? And remove them from the start of the level.


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on February 27, 2010, 02:54:34 PM
try :

Code:
if (kJumpPressed)
{
     sprite_index = [{FLYING SPRITE}]
}

EDIT: NINJA'D!!!

Where do I put this?

And answer Kirby too
How would I add flares to the HUD? And remove them from the start of the level.


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on February 27, 2010, 02:55:26 PM
In readding flares, how would you change kFlarePressed ?


Title: Re: Game Maker Help Thread!
Post by: banna8 on February 27, 2010, 02:57:20 PM
scrCharacterStepEvent for gummy, and im looking for kirby's answer.

KIRBY!! there are two hunks of code commented out in the step event of oPlayer1 in the action block. They are at lines 13 and 945. Un comment those out.

in scrEntityGen, comment out the flarecrate spawning part at line 528


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on February 27, 2010, 03:03:15 PM
Thanks, and how do I make it so that only when I'm in that sprite and I touch the ceiling, I change sprites?  ( I dont know how to do the ceiling part)


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on February 27, 2010, 03:05:53 PM
 collision_point(x+8, y-1, oSolid, 0, 0

might be what you looking for gummy


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on February 27, 2010, 03:48:42 PM
Thanks! and is there suppose to be a ) at the end?


Title: Re: Game Maker Help Thread!
Post by: Kirby on February 27, 2010, 03:49:10 PM
How would I make an object glow?


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on February 27, 2010, 03:51:14 PM
Edit the sprite (somewhere under colorize)


Title: Re: Game Maker Help Thread!
Post by: banna8 on February 27, 2010, 04:07:32 PM
No, I'm pretty sure he means light glow, like in a dark level.

go to oScreen, and in the begins step event you will see a long list of objects. Copy and paste one of those, replacing the object with your own. Edit the other variables as well if you wish.


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on February 27, 2010, 05:15:13 PM
try :

Code:
if (kJumpPressed)
{
     sprite_index = [{FLYING SPRITE}]
}

EDIT: NINJA'D!!!

When I do that, the sprite shows for a second when I press jump..... and only when I press jump..... I meant that the sprite stays until I touch a surface


And how do I change how the character is affected by spiderwebs? (Not for vampire mod)


Title: Re: Game Maker Help Thread!
Post by: Sudonimus on February 27, 2010, 05:27:20 PM
That depends. Whaddaya wanna change it to?
What mod?


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on February 27, 2010, 05:28:51 PM
I want to make the character NOT affected by spiderwebs at all

And I still need this answered too
try :

Code:
if (kJumpPressed)
{
     sprite_index = [{FLYING SPRITE}]
}

EDIT: NINJA'D!!!

When I do that, the sprite shows for a second when I press jump..... and only when I press jump..... I meant that the sprite stays until I touch a surface


Title: Re: Game Maker Help Thread!
Post by: Sudonimus on February 27, 2010, 05:36:24 PM
Oh well, it's not in the oWeb object.


Title: Re: Game Maker Help Thread!
Post by: banna8 on February 27, 2010, 05:45:25 PM
Gummy, use kJump instead of kJumped, and as long as you hold it, the sprite will stay.


Title: Re: Game Maker Help Thread!
Post by: Sudonimus on February 27, 2010, 05:57:08 PM
I found it!
It's in the characterStepEvent, line 744:
Code:
// Stuck on web or underwater
    if (collision_point(x, y, oWeb, 0, 0))
    {
        xFric = 0.2;
        yFric = 0.2;
        fallTimer = 0;
    }
Yay! I'm helpful!


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on February 27, 2010, 06:29:20 PM
THanks, why are you so happy?  You didn't think you could be helpful?  Now, I'm gonna credit you in the mod I'm making (not vamp)

And Banna8, I want it to do it when I double jump, and then stay until I touch a surface.  Once I double jump, I want the sprite to be the permanent sprite whether I press Z or nor.... until I touch a surface


Title: Re: Game Maker Help Thread!
Post by: Sudonimus on February 27, 2010, 07:15:09 PM
THanks, why are you so happy?  You didn't think you could be helpful?  Now, I'm gonna credit you in the mod I'm making (not vamp)
Aww... You don't gotta do that...

And anyways, try something like "if you're in air AND you press this, do this."
And "if I'm this, and I touch a surface, do this."
I don't know; I"m not a coder!!


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on February 27, 2010, 08:22:02 PM
THanks, why are you so happy?  You didn't think you could be helpful?  Now, I'm gonna credit you in the mod I'm making (not vamp)

And Banna8, I want it to do it when I double jump, and then stay until I touch a surface.  Once I double jump, I want the sprite to be the permanent sprite whether I press Z or nor.... until I touch a surface

Gracias Sudo, but I need actual/100% sure help. 


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on February 28, 2010, 01:58:59 AM
Can I get some help with an arrow trap that fires 3 arrows at random speeds?

I got so close but the arrows just kinda stop..


Title: Re: Game Maker Help Thread!
Post by: TailorTF on February 28, 2010, 03:47:24 AM
Maybe put something like?
"
instance_create (x,y,oArrow)
other.x(or y)Vel = rand(1,10)
"


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on February 28, 2010, 09:29:03 AM
How do I make an enemiy ignore the player?


Title: Re: Game Maker Help Thread!
Post by: Kirby on February 28, 2010, 10:02:17 AM
What's the script for calling an explosion to a certain object?


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on February 28, 2010, 10:17:26 AM
How do I make an enemy ignore the player?

And where's the script for the text at the beginning of levels?


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on February 28, 2010, 11:04:53 AM
Maybe put something like?
"
instance_create (x,y,oArrow)
other.x(or y)Vel = rand(1,10)
"
You think that would work, but no, has to do oArrowtest which is the "seeing" of the arrow trap AND the thing that fires, making oArrowtest2 didn't work so far..


Title: Re: Game Maker Help Thread!
Post by: Sudonimus on February 28, 2010, 02:41:34 PM
How do I make an enemy ignore the player?

And where's the script for the text at the beginning of levels?
When colliding with oEnemy; you lose a life.
Put a collision event with whatever enemy/ies you want to ignore you.
And so basically:
Code:
{
//nothing goes here.
}


Title: Re: Game Maker Help Thread!
Post by: Kirby on February 28, 2010, 04:33:52 PM
How would I add more areas?


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on February 28, 2010, 04:35:20 PM
I got the arrows fixed, so the question is... mute. (is that how you would say that?)

Anyway, I wouldn't know how to add new areas.


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on February 28, 2010, 05:29:11 PM
How do I make an enemy ignore the player?

And where's the script for the text at the beginning of levels?
When colliding with oEnemy; you lose a life.
Put a collision event with whatever enemy/ies you want to ignore you.
And so basically:
Code:
{
//nothing goes here.
}

Thanks Sudo! One step closer to finishing Spidey and Vamp!


Title: Re: Game Maker Help Thread!
Post by: kinnik on February 28, 2010, 06:03:21 PM
The code for the random poem at the beginning? :)

Inside 'oIntro' object, inside the 'Create' event, inside the 'Execute a peice of code'

(I hate 'execute a..' as it's not able to be searched and should have been put into a script)

str = "";
n = rand(1,10); // Change this to the amount of different poem lines
switch (n)
{
    case 1: { str1 = "AS THE MOON SEAN BRIGHT ABOVE,"; break; }
    case 2: { str1 = "WITH THE DESERT STRETCHING BEHIND ME,"; break; }
    case 3: { str1 = "AFTER I DOUBLE-CHECKED MY MAP,"; break; }
    case 4: { str1 = "MY LIPS CRACKED AND COVERED IN SAND,"; break; }
    case 5: { str1 = "WITH FATE GUIDING MY EVERY MOVE,"; break; }
    case 6: { str1 = "PUTTING THE FADED PHOTO IN MY POCKET,"; break; }
    case 7: { str1 = "AS I RECALLED MY FATHER'S LAST WORDS,"; break; }
    case 8: { str1 = "MY MEMORY SLIPPING AWAY FROM ME,"; break; }
    case 9: { str1 = "AS I FINISH THE LAST KNIT IN MY SCARF,"; break; }
    case 10: { str1 = "I STARED AT THE STARS,"; break; } //Added with 'case 10:'
}


Title: Re: Game Maker Help Thread!
Post by: kinnik on February 28, 2010, 06:05:42 PM
Kirby:  What do you mean by New Areas??  Like larger levels? or Different/new 'rooms' for exsisting levels?

Or adding all new levels?  Like adding a new black market/boss level or even entirely new 'world/level TYPE'?

I can help with these. ;)


Title: Re: Game Maker Help Thread!
Post by: Kirby on February 28, 2010, 06:10:39 PM
Kirby:  What do you mean by New Areas??  Like larger levels? or Different/new 'rooms' for exsisting levels?

Or adding all new levels?  Like adding a new black market/boss level or even entirely new 'world/level TYPE'?

I can help with these. ;)

That's what I mean.


Title: Re: Game Maker Help Thread!
Post by: kinnik on February 28, 2010, 06:28:45 PM
This might require alot of tinkering as the code is spread out across many scripts and objects..  I will write a tutorial on it now but it will require some trial and error to get it all right without any bugs.  I would love to add a new first level that is above ground!  I'll start writting a tutorial after I do afew things around the house and I'll post the tutorial as a new thread in the source section.


Title: Re: Game Maker Help Thread!
Post by: Sudonimus on February 28, 2010, 07:10:57 PM
That would be great...


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on February 28, 2010, 08:10:41 PM
The code for the random poem at the beginning? :)

Inside 'oIntro' object, inside the 'Create' event, inside the 'Execute a peice of code'

(I hate 'execute a..' as it's not able to be searched and should have been put into a script)

str = "";
n = rand(1,10); // Change this to the amount of different poem lines
switch (n)
{
    case 1: { str1 = "AS THE MOON SEAN BRIGHT ABOVE,"; break; }
    case 2: { str1 = "WITH THE DESERT STRETCHING BEHIND ME,"; break; }
    case 3: { str1 = "AFTER I DOUBLE-CHECKED MY MAP,"; break; }
    case 4: { str1 = "MY LIPS CRACKED AND COVERED IN SAND,"; break; }
    case 5: { str1 = "WITH FATE GUIDING MY EVERY MOVE,"; break; }
    case 6: { str1 = "PUTTING THE FADED PHOTO IN MY POCKET,"; break; }
    case 7: { str1 = "AS I RECALLED MY FATHER'S LAST WORDS,"; break; }
    case 8: { str1 = "MY MEMORY SLIPPING AWAY FROM ME,"; break; }
    case 9: { str1 = "AS I FINISH THE LAST KNIT IN MY SCARF,"; break; }
    case 10: { str1 = "I STARED AT THE STARS,"; break; } //Added with 'case 10:'
}
I meant like I hear snakes!  I hate snakes!  And stuff like that


Title: Re: Game Maker Help Thread!
Post by: Kegluneq on February 28, 2010, 08:14:47 PM
oPlayer1
Look at the alarm events.


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on February 28, 2010, 08:17:03 PM
Thanks!  And Sudo, sorry but that's not what I meant, I meant that I want the caveman not to sprint at you even when you're right if front of him, spiders not to fall on you, vampires not to notice you......etc


Title: Re: Game Maker Help Thread!
Post by: Kegluneq on February 28, 2010, 08:18:43 PM
Something to do with the if (blah blah about distance) statements in each baddie.


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on February 28, 2010, 10:10:45 PM
How do I make the player able to run faster?


Title: Re: Game Maker Help Thread!
Post by: Kegluneq on February 28, 2010, 10:54:05 PM
Blegh for double post.

Should be the same place as the gravity.


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on March 01, 2010, 03:01:29 PM
Sorry, meant to remove

*removes prior post

It doesnt work, I change the vel and acc but he stays the same

So....................
Anybody know how to make Spelunker run faster?
Anybody know where the code for Collision of webball with oCharacter is? (not in oWebBall)


Title: Re: Game Maker Help Thread!
Post by: Arucard on March 01, 2010, 03:02:07 PM
How do I make the player able to run faster?
In the character step script, scroll down to line 799. You should see a comment heading //Running. On this line you will find the x velocity limiter (default 3) change this to a higher number, you'll have to play with the numbers to find what works for you.

That alone won't really work, you also want to open the character create script (the one that has the gravity code as Keg mentioned). On line 65 you'll find the running acceleration variable. Change this to a higher number as well (I used 10 in both which was probably quite a bit faster than what you'll want).

Keep in mind this only changes the walking speed though, holding run will make you "run" at normal "running" speed. Jumping will be affected though. I'll have to keep checking for the run button, unless someone else finds it.


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on March 01, 2010, 03:33:59 PM
I need to know how to run, not walk, faster.

I also need to know if web balls turn into webs if they collide with you


Title: Screens and Colors
Post by: banna8 on March 01, 2010, 05:22:29 PM
When Game Maker asks for colors, can I use (r,g,b) values in place of the presets, and if so, how?

Also, can I draw anything in front of the HUD? That would be very useful.


Title: Re: Game Maker Help Thread!
Post by: MagiMaster on March 01, 2010, 06:04:50 PM
The make_color_rgb can make any color you want and can be used in place of preset colors anywhere in the code.

Things can be drawn in front of the HUD if the object drawing them has a lower depth than what draws the HUD.

In the mushroom mod, I upped the move speed by adding a multiplier to all of the x velocities/accelerations/limits in the movement code (I forgot which script exactly, but it was just one). It should be doable to either apply a constant adjustment to the running speeds, or a variable multiplier that's changed when running.


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on March 01, 2010, 06:50:54 PM
I change everything in either the create or step?


Title: Re: Game Maker Help Thread!
Post by: Sudonimus on March 01, 2010, 06:53:37 PM
Well; think.
It's based on events; so when a certain event happens, eg. something is created; perform certain actions. step is when the game takes... a step. so go from there.


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on March 01, 2010, 06:55:47 PM
Okay, but I think it didnt work before, but I'll try again


Title: Re: Game Maker Help Thread!
Post by: Sudonimus on March 01, 2010, 07:18:30 PM
Well, whaddaya plan on doing?
And, in response to your question, by the way I see it, the Create event just sets the variables.
I don't know. Not fair.


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on March 01, 2010, 07:46:39 PM
So I should change only the X stuff in STEP code?


Title: Re: Game Maker Help Thread!
Post by: Sudonimus on March 01, 2010, 07:54:22 PM
Change it depending on where the controls are.


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on March 01, 2010, 08:22:39 PM
Not the BUTTON X!   I meant the X-Axis stuff!


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on March 01, 2010, 09:52:11 PM
Not the BUTTON X!   I meant the X-Axis stuff!

And I'm adding a new item, oWebBall2 (because the normal one causes an error) and oWebShoot (the sprite for the shoot (the bullet from a gun))....

Everything works, except I get this error
ERROR in
action number 3
of  Step Event
for object oPlayer1:

Error in code at line 143:
       if (holdItem.cost > 0 and isLevel())
                    ^
at position 19: Unknown variable cost

If I can solve this, next version is out!


Title: Re: Game Maker Help Thread!
Post by: kinnik on March 01, 2010, 09:55:15 PM
Hello all. I'm imersed in learning about maze generation but I wanted to take a break and give some ideas to the folk who are doing the Copy Challenge. I'm trying to find where in all the script that the program actualy starts. I'm thinking it's the oScreen object but I'm not positive... Does anyone have the answer or ideas about it?


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on March 02, 2010, 09:58:04 PM
I fixed it!  Now, if you press D, you can shoot a web!  But I don't know why, but I cant press X when I'm holding a bomb or rope ( I did not make a new HUD item)

And I can't pick up items..........

Where is the code/are the codes for that? 

EDIT: I used Darius' tutorial on page 8 to make the "D" button the web button.... the place where it says PUT STUFF HERE, I put

            if (facing == LEFT and firing == 0)
            {
                obj = instance_create(x-9, y-2, oWebShootL);
                obj.xVel = (-1 * rand(6,8)) + xVel;
                if (obj.xVel >= -6) obj.xVel = -6;
                obj.yVel = 0;
                if (state != HANGING and state != CLIMBING)
                {
                    yVel -= 1;
                    xVel += 0;
                }
                playSound(global.sndShotgun);
                firing = firingPistolMax;
            }
            else if (facing == RIGHT and firing == 0)
            {
                obj = instance_create(x+8, y-2, oWebShootR);
                obj.xVel = rand(6,8) + xVel;
                if (obj.xVel < 6) obj.xVel = 6;
                obj.yVel = 0;
                if (state != HANGING and state != CLIMBING)
                {
                    yVel -= 1;
                    xVel += 0;
                }
                playSound(global.sndShotgun);
                firing = firingPistolMax;
            }
            }
        }
    }   

And I took out some stuff and that's what's causing it, I checked.  I took this out and the picking up stuff worked fine


Title: Re: Game Maker Help Thread!
Post by: DariusK on March 03, 2010, 09:00:06 AM
Hey, happy to see you found a use for my tutorial!  :D


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on March 03, 2010, 02:38:10 PM
I fixed it!  Now, if you press D, you can shoot a web!  But I don't know why, but I cant press X when I'm holding a bomb or rope ( I did not make a new HUD item)

And I can't pick up items..........

Where is the code/are the codes for that? 

EDIT: I used Darius' tutorial on page 8 to make the "D" button the web button.... the place where it says PUT STUFF HERE, I put

            if (facing == LEFT and firing == 0)
            {
                obj = instance_create(x-9, y-2, oWebShootL);
                obj.xVel = (-1 * rand(6,8)) + xVel;
                if (obj.xVel >= -6) obj.xVel = -6;
                obj.yVel = 0;
                if (state != HANGING and state != CLIMBING)
                {
                    yVel -= 1;
                    xVel += 0;
                }
                playSound(global.sndShotgun);
                firing = firingPistolMax;
            }
            else if (facing == RIGHT and firing == 0)
            {
                obj = instance_create(x+8, y-2, oWebShootR);
                obj.xVel = rand(6,8) + xVel;
                if (obj.xVel < 6) obj.xVel = 6;
                obj.yVel = 0;
                if (state != HANGING and state != CLIMBING)
                {
                    yVel -= 1;
                    xVel += 0;
                }
                playSound(global.sndShotgun);
                firing = firingPistolMax;
            }
            }
        }
    }   

And I took out some stuff and that's what's causing it, I checked.  I took this out and the picking up stuff worked fine

By the last line, I meant that when I put this in, I couldn't pick stuff up but when I took it back out, I could pick up stuff again.  So it's something to do with the code why I cant pick stuff up


Title: Re: Game Maker Help Thread!
Post by: ipwnu1337 on March 03, 2010, 05:49:16 PM
Question:

How do you add a new hand space?
As in, being able to hold two items, like shotguns, at the same time?

I'm looking to make a dual-wielding mod, but whenever I try to add the "second hand" I can not pick up items or use them.


Title: Re: Game Maker Help Thread!
Post by: DariusK on March 03, 2010, 06:46:36 PM
If you read my rock item tutorial I do explain the item-switching code. I won't lie, it's tricky stuff to deal with, you're really going to need to understand how the code works to modify it effectively. Took me almost half a day to learn.

http://mossmouth.com/forums/index.php?topic=703.0


Title: Re: Game Maker Help Thread!
Post by: MagiMaster on March 03, 2010, 06:56:21 PM
Hello all. I'm imersed in learning about maze generation but I wanted to take a break and give some ideas to the folk who are doing the Copy Challenge. I'm trying to find where in all the script that the program actualy starts. I'm thinking it's the oScreen object but I'm not positive... Does anyone have the answer or ideas about it?

oLevel, oGame and several oRooms already exist when the level begins. GameMaker doesn't really have a starting point a such. Instead, objects that already exist use their create/roomStart/step/etc. events to manipulate the game.


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on March 03, 2010, 07:12:39 PM
I'm adding a new action button (2 in fact).

I added one, and it works (laser in Iron Man)
But when I copy and paste for the second one, and change all the necessary stuff, it doesn't work......... am I allowed to add 2 action buttons?


Title: Re: Game Maker Help Thread!
Post by: ipwnu1337 on March 03, 2010, 08:27:46 PM
If you read my rock item tutorial I do explain the item-switching code. I won't lie, it's tricky stuff to deal with, you're really going to need to understand how the code works to modify it effectively. Took me almost half a day to learn.

http://mossmouth.com/forums/index.php?topic=703.0

Were you answering gummy?  I'm not too sure.

I was asking if there was a way to make it so you can wield 2 items at the same time, like two shotguns.

I'm in the process of making a new action button, which replaces "V", so that you can use "V" similar to the way you use the "X" key, or the attack key.

Whenever I try to get something done with it, I cannot pick up items at all.

Wierd.


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on March 03, 2010, 08:29:30 PM
I keep getting messed up when I add more than one action button!  I added 3 and now bomb and rope are switched (C) and you cant throw or use items!


Title: Re: Game Maker Help Thread!
Post by: Kegluneq on March 03, 2010, 09:15:41 PM
The game "starts" with the first room in the room folder, and any objects in that room.


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on March 04, 2010, 03:52:39 PM
I want to fix my Iron Man and Spidey mod....

Can someone tell me where to copy and paste the code for the new buttons to the oPlayer1 Step, because I'm using a portion of scrUseItem and there are serious bugs as a result


EDIT: I GOT IT FIXED! YAY YAY YAY!!!! NEW UPDATES FOR BOTH TODAY!! BUT WITIHOUT BUGS!!!!!


Title: Re: Game Maker Help Thread!
Post by: halibabica on March 04, 2010, 05:56:43 PM
Okay, so, I've just about finished up with the Spelunker foe for my mod, but I'm having a problem making him use the Machete.

I got the variables and animations and such all down just fine, but I can't get it to stop creating oSlash when the time comes.  When oPlayer1 uses it, there's the requirement 'instance_number (oWhip) == 0', but the same thing didn't work for the foe.  I'm at a loss how to stop it.


Never mind, I figured it out.  There was an incorrect object type and an extra equals sign involved.


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on March 04, 2010, 07:39:35 PM
It just does it when you didn't even press it?  THat happened to me with the new action buttons, check over the Step Code for player1 and the object's step code


Title: Re: Game Maker Help Thread!
Post by: Kegluneq on March 05, 2010, 11:54:34 PM
Search after search, I just can't find out where the code for the view following Spelunker is.

Anyone?


Title: View
Post by: banna8 on March 06, 2010, 08:00:41 AM
Isn't it a setting in the rooms? That's what it is for a lot of Game Maker Games.


Title: Re: Game Maker Help Thread!
Post by: Arucard on March 06, 2010, 08:56:06 AM
I think that's right, the room "level" has views enabled following oPlayer1. I assume the rest are the same, other than the cutscenes.


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on March 06, 2010, 11:27:00 AM
Thats what I thought, and talked to him about, but no that doesn't work, it dones't change ANYTHING to have that.


Title: Re: Game Maker Help Thread!
Post by: Kegluneq on March 06, 2010, 03:07:45 PM
Thats what I thought, and talked to him about, but no that doesn't work, it dones't change ANYTHING to have that.
This.


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on March 06, 2010, 03:08:32 PM
Hey can some one help me with level feelings? I made two new ones but the message only shows if there is two messages playing..


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on March 06, 2010, 03:50:48 PM
1. Where is the code for killing things mario style?

2. Where is the code/What is the code for ceilings? OR How do I make it so that the sprite changes when I touch a ceiling?


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on March 06, 2010, 04:08:32 PM
1. Where is the code for killing things mario style?

2. Where is the code/What is the code for ceilings? OR How do I make it so that the sprite changes when I touch a ceiling?
1) In each bad guy.
2) Look at bats


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on March 06, 2010, 04:36:07 PM
Thanks!!!

And what else do I need to do if I wanna make an enemy besides make the sprite, object, and codes?


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on March 06, 2010, 04:40:43 PM
That sounds about it. but the code is hard mind you.


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on March 06, 2010, 04:52:44 PM
And how do I make it so that you freeze when you're in that state (unless you press _)


Title: Re: Game Maker Help Thread!
Post by: kinnik on March 06, 2010, 05:31:16 PM
I would be very happy if people started making new enemys!  I'll try and help with the coding part.. It might be a good idea to start with enemys with similar atacks to exsisting ones.


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on March 06, 2010, 06:02:15 PM
Again, look at my suggestions!

I still need this answered

And how do I make it so that you freeze when you're in that state (unless you press _)


Title: Re: Game Maker Help Thread!
Post by: kinnik on March 06, 2010, 07:55:39 PM
Hey Kegluneq! I found your code for following who..

oScreen -> create -> last 'execute'...
it still uses the built in follow feature but it sets it for each room


Title: Re: Game Maker Help Thread!
Post by: Kegluneq on March 06, 2010, 08:03:03 PM
Kickass! That's just what I needed!

Sorry for the language ya'll, I'm just excited to have found it.


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on March 06, 2010, 08:13:57 PM
Found what?  What does that do?


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on March 06, 2010, 08:14:34 PM
don't worry gummy, just know 2 player is doing better.

Anyway, level feelings? anyone help?


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on March 06, 2010, 08:18:32 PM
Hey can some one help me with level feelings? I made two new ones but the message only shows if there is two messages playing..

What do you mean by 2 messages playing?

(I STILL need this answered
And how do I make it so that you freeze when you're in that state (unless you press _) )


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on March 06, 2010, 08:37:23 PM
Hey can some one help me with level feelings? I made two new ones but the message only shows if there is two messages playing..

What do you mean by 2 messages playing?

(I STILL need this answered
And how do I make it so that you freeze when you're in that state (unless you press _) )
In other words, if you get an evil  level and a snake level both play like if you get a dark and snake level, but if you only get an evil level...


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on March 06, 2010, 09:45:18 PM
MGG, can you please just tell me the ceiling-touch code because I can't find it, and when I DO "find" it, it works funnily


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on March 06, 2010, 10:01:55 PM
I already did and you didn't even seem to care
Code:
if (collision_point(x+8, y-1, oSolid, 0, 0)) status = HANG;


thats the bats code.



Title: Re: Game Maker Help Thread!
Post by: kinnik on March 06, 2010, 10:04:30 PM
Hey Gummy:  it would help me if you explain (or link where you do) what is your trying to do. To do with ceiling collision, that is...

if your looking for the code that changes the bats status from attack to hang, it is in the oBat object -> step action -> at the very bottem.
It reads as follows:


    if (collision_point(x+8, y-1, oSolid, 0, 0)) status = HANG;
    else
    {
        dir = 90;
        xVel = 1 * cos(degtorad(dir));
        yVel = -1 * sin(degtorad(dir));  
    }


Ah, MGG beat me... ill post anyhow ;P


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on March 06, 2010, 10:05:42 PM
he did explain what he watned to do, he is making vamp mod and he wants it when your in bat form you can hang on the roof.

(which sounds cool)


Title: Re: Game Maker Help Thread!
Post by: kinnik on March 06, 2010, 10:34:15 PM
oPlayer1 step action ->
if (kUp and collision_point(x+8, y-1, oSolid, 0, 0)) state = HANGING;

??

I'm sure that is way too simple to work...

...nope, but you can glide up the walls ;)

try reading through characterStepEvent in scripts->platform engine line > 396 to learn about hanging as it relates to the player.


if (hangCount == 0 and y > 16 and !platformCharacterIs(ON_GROUND) and kUp and colUp and (collision_point(x+8, y-1, oSolid, 0, 0) or collision_point(x+8, y-2, oSolid, 0, 0)))
    {
        state = HANGING;
        move_snap(1, 8);
        yVel = 0;
        yAcc = 0;
        grav = 0;
    }


doesn't work either...  ???


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on March 07, 2010, 11:31:57 AM
I already did and you didn't even seem to care
Code:
if (collision_point(x+8, y-1, oSolid, 0, 0)) status = HANG;


thats the bats code.

That's what I meant by "didn't work".  Those coordinates are relative to the bat's center which is 0, 0.  oPlayer1's center point is 8, 8 and therefore, I had to change the coordinates... But thanks anyway.

And Kinnik, that's helpful, thanks.  But as you said, it doesn't really work.

EDIT: I got it!  But there's a mess-up..... I created a new state and used that state to make active = 0;.  Here's the state

if (kFlap and collision_point(x, y-9, oSolid, 0, 0)) kFlappers = kFlap and collision_point(x, y-9, oSolid, 0, 0);
else kFlappers = false;


(Yea, I know, I called it kFlappers)

And here's the code:

if kFlappers
{
sprite_index = sVHang
active = false;
kJumpPressed = true;
}

(sVHang is the hanging vampire sprite)


But when I do that, it works, but I can't move at all once I turn into hanging bat... I tried making another state in which when kFlappers and kJump happens, active = true, but that didn't work out....... I think all I have to do is add something to the code or change the active = false; to something else........


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on March 07, 2010, 11:35:44 AM
yeah he can't do anything once you deactivate  him


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on March 07, 2010, 11:36:33 AM
Can't I do something like active = false UNLESS ______?

If not, what should I put instead of the active = false?


Title: Re: Game Maker Help Thread!
Post by: banna8 on March 07, 2010, 12:05:16 PM
put something like this:

Code:
if (UNLESS)
{
state = true
}
else
{
state = false
}


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on March 07, 2010, 12:40:05 PM
What's the "(UNLESS)"?

And I don't get that code...

I want to get "stuck" in a position/state UNTIL I press Jump

EDIT: It works!!! I GOT IT!!!!!!!!!!!!!!!

if kFlappers
{
sprite_index = sVHang
active = false;
}
    if (checkJumpPressed() and state != DUCKING and state != DUCKTOHANG and not whipping and
    sprite_index != sPExit and sprite_index != sDamselExit)
    {
    active = true;
    }


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on March 07, 2010, 01:02:40 PM
glad to hear it but you didn't need to double post


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on March 07, 2010, 01:07:26 PM
 :-[ Sorry, I removed the post before it now.



Title: Re: Game Maker Help Thread!
Post by: hyperme on March 07, 2010, 01:48:56 PM
How do I make an enemy spawn and use weapons.  I want to make one that uses either a machete or bow.


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on March 07, 2010, 01:50:41 PM
Look at the shopkeeper, he can show you how.l


Title: Re: Game Maker Help Thread!
Post by: hyperme on March 07, 2010, 02:16:45 PM
I tried that.  And I'm still not sure how it works.


Title: Re: Game Maker Help Thread!
Post by: halibabica on March 07, 2010, 02:27:16 PM
It's part of his Draw event.  There's a bit of code where it's like:

if (hasGun and angered)
draw_sprite = sShotgunLeft

...or something like that.  That's what makes the weapon visible on his person.  The code to make him fire it is under his Step event where it says "if (status == ATTACK)".

I mimicked him entirely to make the Spelunker and Tunnel Man foes in TLS.


Title: Re: Game Maker Help Thread!
Post by: hyperme on March 07, 2010, 02:42:21 PM
The draw bit was what i needed to know. Hurrah!  Now I can create Jiang-shi soldiers!


Title: Re: Game Maker Help Thread!
Post by: banna8 on March 07, 2010, 05:04:58 PM
Let's say for ambiguity's purpose that I want to add a "worm" to spelunky.

I want a small (8 x 8 ) ball to be throwable, and when it hits a surface it spawns a worm. The worm will move right if I throw the ball to the right, and move left if I throw the ball left. {done}

However, I want to make it so that if I throw it at a wall on my right, it will move up. and if I throw it at a wall to my left, it will go down. I can't seem to use isCollision's properly. {kinda hard}

Also, if the worm hits a wall while moving, I want it to start going up. If it goes off of a ledge, I want it to go down and wrap around the platform like this:

 :spl-gold:

 :spl-bl01:   :spl-bl01:
 :spl-batf:   :spl-batf:

(Start at the gold, then wrap under and go allong the ceiling in the direction the bats are going) {super extra hard?}


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on March 07, 2010, 08:24:39 PM
Haha, I just noticed that the 8)  is supposed to be an 8 and a )!

You want it to trace a wall?  Keep going around the whole level?  I have no idea how to do that............

(Also, I need this answered,

"Where is the code for when the ghost message comes up?  Not the ghost itself, but the message)


Title: Re: Game Maker Help Thread!
Post by: idoru on March 07, 2010, 08:31:04 PM
"Where is the code for when the ghost message comes up?

Line 31 of the step code for oGame.


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on March 07, 2010, 09:05:09 PM
THank you! 


Title: Re: Game Maker Help Thread!
Post by: kinnik on March 08, 2010, 01:28:44 AM
Hiya,  I'm working on adding gamepad support to multiSpelunky...  I'm stuck because I don't know what gamepad.whatever in the control scripts is refering to.  Is it refering to the oGamepad object?  it dosn't seem like it as it should read oGamepad.whatever not just gamepad.whatever...

like in script : controls -> checkLeftPressed

if (gamepad.leftPressed)
    return gamepad.leftPressed;

how does this code know what gamepad.leftPressed is?!

I'm probly just being dumb... help please!


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on March 08, 2010, 01:45:16 AM
Hiya,  I'm working on adding gamepad support to multiSpelunky...  I'm stuck because I don't know what gamepad.whatever in the control scripts is refering to.  Is it refering to the oGamepad object?  it dosn't seem like it as it should read oGamepad.whatever not just gamepad.whatever...

like in script : controls -> checkLeftPressed

if (gamepad.leftPressed)
    return gamepad.leftPressed;

how does this code know what gamepad.leftPressed is?!

I'm probly just being dumb... help please!
There already is game pad support.

so um.. yeah.


Title: Re: Game Maker Help Thread!
Post by: kinnik on March 08, 2010, 01:49:48 AM
Ok smartypants... how do you keep the gamepad from controling both players?

Jk,  but I need to seperate gamepad 1 from gamepad 2 and send it to the right player.

Still, I can't find where or what gamepad.whatever is..


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on March 08, 2010, 01:53:39 AM
Oh sorry I miss read that. my bad.



Title: Re: Game Maker Help Thread!
Post by: kinnik on March 08, 2010, 02:01:09 AM
 ;D   I changed it to read oGamepad and oGamepad2 and I think it will work... t I still don't know what gamepad.* without the little 'o' is talking about.



Edit:  AH Geeze.... in the scrIni gamepad is the instance variable for oGamepad


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on March 08, 2010, 10:00:46 PM
How do I make it so that the shoppy gets mad when you enter his shop or get within a certain radius?


Title: Re: Game Maker Help Thread!
Post by: AresRomanGod on March 09, 2010, 04:50:17 PM
Do I really need to pay 25$ to make my own mod?


Title: Re: Game Maker Help Thread!
Post by: smokcheez on March 09, 2010, 04:56:51 PM
Only if you want to make it by yourself fully. You could use GM litetm and sprite things and send it to someone with GM pro, though.


Title: Re: Game Maker Help Thread!
Post by: kinnik on March 09, 2010, 04:59:46 PM
Del: I PM U.

gummy:  shopkeeper->step action-> line 119

if (global.murderer or global.thiefLevel > 0 or global.isVampire)//???yeah
    {
        status = PATROL;
    }

also line 85

if ((status == PATROL or status == WALK))
{
    if (not oPlayer1.dead and distance_to_object(oPlayer1) < 64 and oPlayer1.y - (y+8) < 16)
    {
        status = ATTACK;
    }
    else if (abs(oPlayer1.x-(x+8)) < 4)
    {
        status = ATTACK;
    }
}

looks like something to play around with...

I *know* ive seen more stuff on theft and stuff... parhaps in oPlayer code... Donno
use the search functions (search scripts AND the edit->show object information->copy to doc->notepad->contol 'f'    to search everything for "global.murderer or global.thiefLevel"


Title: Re: Game Maker Help Thread!
Post by: Sudonimus on March 09, 2010, 05:32:28 PM
Do I really need to pay 25$ to make my own mod?
No, in fact, Gummy and ipwnu pirated their copies.
(And... *chuckles sheepishly*... moi...)
So paying isn't the only option, but I wouldn't want to know that I helped someone steal something worth money.
(And it really isn't WORTH 25 dollars, it's just what you DO with it is.)
GM Pro, I think, doesn't show the GM logo when the game is loading, it lets you use some new color effects like color gradient, it lets you make internet games...
Yeah, what I like best is the GM logo part.


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on March 09, 2010, 05:54:38 PM
Do I really need to pay 25$ to make my own mod?
No, in fact, Gummy and ipwnu pirated their copies.
(And... *chuckles sheepishly*... moi...)
So paying isn't the only option, but I wouldn't want to know that I helped someone steal something worth money.
(And it really isn't WORTH 25 dollars, it's just what you DO with it is.)
GM Pro, I think, doesn't show the GM logo when the game is loading, it lets you use some new color effects like color gradient, it lets you make internet games...
Yeah, what I like best is the GM logo part.
Can we talk about stealing GM?
I mean isn't that bad thing to talk about out in the open here?


Title: Re: Game Maker Help Thread!
Post by: kinnik on March 09, 2010, 05:59:50 PM
very likely, yes. but, whatever. I bet alot of folk here are dirt poor (me) and new to programming and wouldn't buy GM untill they know thier really into it.  I'd like to support GM when I get a job again and can do so without feeling guilty... not to mention my GF would probly rip on me ;P

Mind you, 25$ is a *fantastic* deal!  Most commecial programming enviroments cost hundreds of dollers... even 'Click and Play' (circa 1990's) cost 60$ when it came out. and it SUCKED compaired to GM.  Or how about Blitz Basic 80 to 100$?!?!?!? Damb, what a ripoff!!


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on March 09, 2010, 06:03:48 PM
I also thought it was so easy to steal that no one would have to talk about it, I mean i get bugged by all the links to the stolen version I run into.


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on March 09, 2010, 09:59:56 PM
How do I make something happen after a CERTAIN time after the last time you did something?

Like, say I wanted a message to come up saying SACRIFICE TO ME, SLAVE! 15 seconds after the last time you sacrificed....

Is the only way with counters and alarms?

If so, how EXACTLY do I do it?


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on March 09, 2010, 10:07:22 PM
alarm[11]=45(or whatever number you like)

make an event for alarm11, the put the messege code there.


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on March 09, 2010, 10:09:34 PM
I want it to show after 15 seconds after the LAST time that I ______'ed


Title: Re: Game Maker Help Thread!
Post by: Kirby on March 09, 2010, 10:12:08 PM
How do I make it so when Tiki Torch's ground beneath them is destroyed, they become oTikiTorchItem? I want it to be like the lamp in that aspect.


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on March 09, 2010, 10:14:50 PM
You have to make the item first and make it holdable.  When the ground below it is destroyed Instance_destroyed and replaced by the item.

So, how do I make something happen after 15 seconds after the last time I did something?  (Like sacrifice or collide)


Title: Re: Game Maker Help Thread!
Post by: grieck on March 09, 2010, 10:16:12 PM
How do I make something happen after a CERTAIN time after the last time you did something?

Like, say I wanted a message to come up saying SACRIFICE TO ME, SLAVE! 15 seconds after the last time you sacrificed....

Is the only way with counters and alarms?

If so, how EXACTLY do I do it?

The Vampire wiill be Kali's Slave? makes sense.

As for pirating GM Pro...though I am a sort of media pirate ( dirt poor mind you, still trying to get a job so I can legally get my music and such), and don't condone pirating GM Pro, if you don't have the  money it's understandable.

Yes it's so easy to steal we need not ttalk of it, but most talk of it seems based around the 'should I' and light bit of 'is it wrong' (or at least light frowning upon it being done) talk.


Title: Re: Game Maker Help Thread!
Post by: Kirby on March 09, 2010, 10:22:46 PM
Yes but where do I edit it?


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on March 10, 2010, 07:44:41 AM
NO NO NO!  I was just giving an EXAMPLE!  I'm doing the blood messages now, where it says I NEED BLOOD... NOW!  After 30 seconds after the last time you collide with blood.  And then you lose 1 HP after every 15 seconds after that message if you don't collide with blood.  If you do, then the counter thing restarts.  (Sorry if I seem angry)


Title: Re: Game Maker Help Thread!
Post by: halibabica on March 10, 2010, 08:27:17 AM
Okay, you need to set two new variables called 'bloodTimer' and 'bloodTimerMax' or something like that (name it so you know what it's for).  Set them equal to the same amount at first.  Fifteen seconds in GM would be 450.

In the player's step event, set it so that 'if (bloodTimer > 0) bloodTimer -= 1;

Then, add an else case that displays the message you want it to show.  Next, under the event that records the player's collision with blood, put bloodTimer = bloodTimerMax.  That will reset the bloodTimer back to full.

You'll need to take it a bit further than this to make him lose HP when without blood for too long.  But you can probably figure it out from here.


Title: Re: Game Maker Help Thread!
Post by: grieck on March 10, 2010, 01:05:02 PM
Where can I find what decides if oPiranha is replaced with oDeadFish?

And anything related to Level Feelings.


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on March 10, 2010, 02:07:27 PM
Okay, you need to set two new variables called 'bloodTimer' and 'bloodTimerMax' or something like that (name it so you know what it's for).  Set them equal to the same amount at first.  Fifteen seconds in GM would be 450.

In the player's step event, set it so that 'if (bloodTimer > 0) bloodTimer -= 1;

Then, add an else case that displays the message you want it to show.  Next, under the event that records the player's collision with blood, put bloodTimer = bloodTimerMax.  That will reset the bloodTimer back to full.

You'll need to take it a bit further than this to make him lose HP when without blood for too long.  But you can probably figure it out from here.

THANK YOU!!! You're too kind!

Where can I find what decides if oPiranha is replaced with oDeadFish?

And anything related to Level Feelings.

oPiranha probably?  Instance_destroy and instance_create? Like {if hp<1,...etc
And level feelings are in the oPlayer1 alarms... I think


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on March 10, 2010, 02:46:14 PM
Gleenrieck the level genrater puts down dead fish not puting down piranha in a dead level.

what do you want to do? I can help


Title: Re: Game Maker Help Thread!
Post by: grieck on March 10, 2010, 02:49:25 PM
I want so that restless dead will also replace Jaws with an equivalent boney fish thing, once I find that out i will duplicate jaws then replace the sprites.


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on March 10, 2010, 02:54:18 PM
I want so that restless dead will also replace Jaws with an equivalent boney fish thing, once I find that out i will duplicate jaws then replace the sprites.
Look at the level generate code for area 2, there should be a
If restlessdead
Make Dead fish
Else
make living fish.

Just copy and paste and put it where jaws is spawned (make sure to not get rid of the only one per level) and there you go.


Title: Re: Game Maker Help Thread!
Post by: grieck on March 10, 2010, 03:08:41 PM
Ummm...I can't find it is the problem.


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on March 10, 2010, 03:13:40 PM
Just put i

f(restlessdead)
Instance_change(oDeadJaws,true)

there you go


Title: Re: Game Maker Help Thread!
Post by: grieck on March 10, 2010, 03:18:20 PM
Put that where? in the Jaws Code? Becuase I can't find the thing for individual areas, or anything that has then together with more than just names (oPplayer has what the message is, nothing more)


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on March 10, 2010, 03:19:50 PM
in the create event.

that should do it.


Title: Re: Game Maker Help Thread!
Post by: grieck on March 10, 2010, 03:29:16 PM
Just put i

f(restlessdead)
Instance_change(oDeadJaws,true)

there you go

That just creates errors.


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on March 10, 2010, 03:32:26 PM
well thats becuse I missspelled if due to reformating
and did you make oDeadJaws?

ff(restlessdead)
Instance_change(oDeadJaws,true)

there you go


Title: Re: Game Maker Help Thread!
Post by: grieck on March 10, 2010, 04:59:58 PM
working on it


Title: Re: Game Maker Help Thread!
Post by: Kirby on March 10, 2010, 05:03:58 PM
Again, where do I edit the oTikiTorch so when the ground beneath it is destroyed, it becomes oTikiTorchItem. Like how oLamp becomes oLampItem when the ground holding it is destroyed.


Title: Re: Game Maker Help Thread!
Post by: kinnik on March 10, 2010, 05:17:36 PM
glen/mars: doesn't jaws only come on lake levels?  can you have an undead lake level?
if so, the mgg fix sounds ok to me.

global.lake true for lake levels
global.cemetary true for undead

actualy... a parhaps better way to do it would be to alter
this would alowe you to make the undead jaws behave diferently

scrRoomGen2 -> line 393 to read

else if (tile == "J")
        {
            instance_create(xpos, ypos, oWaterSwim);
            instance_create(xpos, ypos, oJaws);
        }

becomes

else if (tile == "J")
        {
            instance_create(xpos, ypos, oWaterSwim);
            if (global.cemetary)
           {
                   instance_create(xpos, ypos, oJawsUndead);
            }
            else
            {
                  instance_create(xpos, ypos, oJaws);
             }
        }


Title: Re: Game Maker Help Thread!
Post by: kinnik on March 10, 2010, 05:19:59 PM
Kirby:  where is the tiki torch object??

oops, found it...

ok  look at oSpearTrapBottom -> step action # 1-> line 82
just a hint for you.

I'm not sure how oLamp does it??!!

I'd like to know tho... anyone?


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on March 10, 2010, 06:59:32 PM
Where are the scripts for what items/collectibles do? (COMPASS)


Title: Re: Game Maker Help Thread!
Post by: kinnik on March 10, 2010, 07:04:10 PM
it depends... the compass is in scrHud
jetpack and cape are in scripts->platform engine->characterStepEvent
bow/guns ect are in scripts->character->scrUseItem


Title: Re: Game Maker Help Thread!
Post by: grieck on March 10, 2010, 07:08:21 PM
I feel like an idiot, I kept freaking out that I couldn't find scripts and stuff.

I wasn't running it in advanced mode.


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on March 10, 2010, 07:20:41 PM
HAHA ;D That happened to me too!

And  THANKS KINNIK! 


Title: Re: Game Maker Help Thread!
Post by: kinnik on March 10, 2010, 08:47:26 PM
OK.. I need help bad!  I'm going NUTS trying to find where (in the code) the oPlayer1 gets instance_create.
Where is it?!?!
 PLEASE ANYONE/EVERYONE HELP ME!!
 
maybe it gets made persistent at some point?
ok... I'm stoping on multiplayer until someone finds this... or atleast untill my headache goes away and i start looking for this *!*@# code again.


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on March 10, 2010, 08:49:57 PM
What do you mean GETS instance_create?

And, how do you change the beginning scene where everything's black and it says DEREK YU PRESENTS


Title: Re: Game Maker Help Thread!
Post by: kinnik on March 10, 2010, 09:08:34 PM
i mean, the player is not simply moved from level to level (room to room in GM speak) as far as i can tell.  it needs to be made with

instance_create(x,y,oPlayer1)

where x and y could be anything... which makes it hard to search for.
I need to find this so that i can add player2 in the same spot and let her travel from level to level with player1 instead of having to be created with the backspace key at the start of every level.


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on March 10, 2010, 10:03:46 PM
I feel like an idiot, I kept freaking out that I couldn't find scripts and stuff.

I wasn't running it in advanced mode.
Never don't run in advanced mode. It's harder not to.


Title: Re: Game Maker Help Thread!
Post by: Kirby on March 10, 2010, 11:20:38 PM
How does that help what I need to do at all?
"if (not collision_point(x, y+16, oSolid, 0, 0))"

Also anybody know the way lamps work at all? Like how they spawn where they are and such. There must be code for the oLamp destroyal to become oLampItem in some script. I really want to get this item working. It should appear in shops, but the shop I put it in rarely appears.


Title: Re: Game Maker Help Thread!
Post by: kinnik on March 11, 2010, 03:03:26 AM
I was thinking...

if (not collision_point(x, y+16, oSolid, 0, 0))
{
    instance_create(x, y, oTikiTorchItem);
    instance_destroy();//this might destroy the object you just made...?maybe not?
}        
    


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on March 11, 2010, 11:12:59 AM
instance_change(oTikitorchitem,true)

would be a lot safer. no point destroying and recreating when you can CHANGE


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on March 11, 2010, 07:20:27 PM
HOW DO I CHANGE "THE DEREK YU PRESENTS..." THING!!!!!!!!!!!!!!!!!!!!
And how do I getthe compass to point at something else?


Title: Re: Game Maker Help Thread!
Post by: banna8 on March 11, 2010, 08:12:26 PM
Let's say for ambiguity's purpose that I want to add a "worm" to spelunky.

I want a small (8 x 8 ) ball to be throwable, and when it hits a surface it spawns a worm. The worm will move right if I throw the ball to the right, and move left if I throw the ball left. {done}

However, I want to make it so that if I throw it at a wall on my right, it will move up. and if I throw it at a wall to my left, it will go down. I can't seem to use isCollision's properly. {kinda hard}

Also, if the worm hits a wall while moving, I want it to start going up. If it goes off of a ledge, I want it to go down and wrap around the platform like this:

 :spl-gold:

 :spl-bl01:   :spl-bl01:
 :spl-batf:   :spl-batf:

(Start at the gold, then wrap under and go allong the ceiling in the direction the bats are going) {super extra hard?}

^ THIS ^ (Halbabica may have some help involving staying on walls......)


Title: Re: Game Maker Help Thread!
Post by: kinnik on March 11, 2010, 09:52:41 PM
Does anyone know where the code for purchasing items?  Like where it takes the money?


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on March 11, 2010, 10:00:14 PM
Does anyone know where the code for purchasing items?  Like where it takes the money?
Um... not quite, I could look up things, what you trying to do?


Title: Re: Game Maker Help Thread!
Post by: halibabica on March 12, 2010, 10:40:40 AM
Does anyone know where the code for purchasing items?  Like where it takes the money?
I think that's in scrStealItem, but I'm not sure.

I have a question about the 'frozen zone' and object instances.  See, I'm adding the Shuriken weapon to my mod, and I want to make it so you can only have three on the stage at a time.  I did the instance_number thing, but if you throw three and move too far away from them, you'll be able to throw more.  Is there any way to make it so there can only be three no matter where they are?


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on March 12, 2010, 11:04:04 AM
Does anyone know where the code for purchasing items?  Like where it takes the money?
I think that's in scrStealItem, but I'm not sure.

I have a question about the 'frozen zone' and object instances.  See, I'm adding the Shuriken weapon to my mod, and I want to make it so you can only have three on the stage at a time.  I did the instance_number thing, but if you throw three and move too far away from them, you'll be able to throw more.  Is there any way to make it so there can only be three no matter where they are?
Yes. Make a variable (ninjastars or the like) in oPlayer1 when he throws have it go down (check to makes sure greater then 0 before throwing) when he gets a new one make it up up 1. When he goes to a new level he should have 3 once more (due to being a new copy of the same object)


Title: Re: Game Maker Help Thread!
Post by: halibabica on March 12, 2010, 11:59:21 AM
Thanks, mars!  Worked like a charm!


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on March 12, 2010, 12:44:42 PM
Np
some times I really do I know what I am doing.


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on March 12, 2010, 03:21:36 PM
I added sneakers and winged shoes to my mod!

1. HOW DO I MAKE THE COMPASS POINT TO SOMETHING ELSE?
2. HOW DO I MAKE ENEMIES IGNORE ME WHEN I AM IN A CERTAIN STATE?
3. HOW DO I MAKE THINGS IN MY HAND DIE WHEN I DO SOMETHING? ( THEY DON'T LEAVE MY HANDS)


Title: Re: Game Maker Help Thread!
Post by: kinnik on March 12, 2010, 04:41:26 PM
1.compass code is in the scrHud.
2.  ??
3.every item has a 'parent' called oItem (look in basic folder in objects) and the oItem has a boolean (true false) called 'held'... look in the oItem step event to see how it works.  the trick might be adressing the item from some other objects code


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on March 12, 2010, 05:31:38 PM
How do I change it so that it points to blood?  It never works for me
I'm still not sure about 3... ???

1. HOW DO I MAKE THE COMPASS POINT TO SOMETHING ELSE?
2. HOW DO I MAKE ENEMIES IGNORE ME WHEN I AM IN A CERTAIN STATE?
3. HOW DO I MAKE THINGS IN MY HAND DIE WHEN I DO SOMETHING? ( THEY DON'T LEAVE MY HANDS)
4. HOW DO I MAKE SOMETHING DISSAPPEAR WHEN I USE IT? (I added the object to scrUseItem but when I add instance_destroy(); I dissappear instead


Title: Re: Game Maker Help Thread!
Post by: grieck on March 12, 2010, 05:47:54 PM
How do I change it so that it points to blood?  It never works for me
I'm still not sure about 3... ???

1. HOW DO I MAKE THE COMPASS POINT TO SOMETHING ELSE?
2. HOW DO I MAKE ENEMIES IGNORE ME WHEN I AM IN A CERTAIN STATE?
3. HOW DO I MAKE THINGS IN MY HAND DIE WHEN I DO SOMETHING? ( THEY DON'T LEAVE MY HANDS)
4. HOW DO I MAKE SOMETHING DISSAPPEAR WHEN I USE IT? (I added the object to scrUseItem but when I add instance_destroy(); I dissappear instead

I remeber the GM 7 Debug mode had something for this (the COMPASS), look for the commands through the wikia on Spelunky, it might give a clue to how.


Title: Re: Game Maker Help Thread!
Post by: TailorTF on March 12, 2010, 06:31:38 PM
How do I get the global.message and global.message2 to work?I'm making an item that creates a message when it collides with the damsel,and it's not working!


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on March 12, 2010, 06:38:01 PM
Code:
instance_activate_object(oDamsel); obj=instance_nearest(oPlayer1.x,oPlayer1.y,oDamsel); global.hasCompass=1;global.exitX=obj.x;global.exitY=obj.y;

No clue for talior's issue.


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on March 12, 2010, 07:15:28 PM
IS that line of code for the damsel-pointing? Thanks!

And I still need these answered
2. HOW DO I MAKE ENEMIES IGNORE ME WHEN I AM IN A CERTAIN STATE?
3. HOW DO I MAKE THINGS IN MY HAND DIE WHEN I DO SOMETHING? ( THEY DON'T LEAVE MY HANDS)
4. HOW DO I MAKE SOMETHING DISSAPPEAR WHEN I USE IT? (I added the object to scrUseItem but when I add instance_destroy(); I dissappear instead


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on March 12, 2010, 08:06:23 PM
2) no clue
3) You need set object in hand to blank. That well do it. I don't know the code of the the top of my head... oh wait its
Code:
with oPlayer1 scrHoldItem("");
4) Same thing


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on March 12, 2010, 08:17:41 PM
For 3, I want the enemy  to die and not dissappear


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on March 12, 2010, 08:21:28 PM
other.hp=0 ?


Title: Re: Game Maker Help Thread!
Post by: MagiMaster on March 13, 2010, 12:35:13 AM
@TailorTF,
global.message = "FIRST LINE OF TEXT HERE";
global.message2 = "SECOND LINE OF TEXT HERE";
global.messageTimer = 120; // or however long you want it to stick around


Title: Re: Game Maker Help Thread!
Post by: banna8 on March 13, 2010, 07:08:01 AM
Let's say for ambiguity's purpose that I want to add a "worm" to spelunky.

I want a small (8 x 8 ) ball to be throwable, and when it hits a surface it spawns a worm. The worm will move right if I throw the ball to the right, and move left if I throw the ball left. {done}

However, I want to make it so that if I throw it at a wall on my right, it will move up. and if I throw it at a wall to my left, it will go down. I can't seem to use isCollision's properly. {kinda hard}

Also, if the worm hits a wall while moving, I want it to start going up. If it goes off of a ledge, I want it to go down and wrap around the platform like this:

 :spl-gold:

 :spl-bl01:   :spl-bl01:
 :spl-batf:   :spl-batf:

(Start at the gold, then wrap under and go allong the ceiling in the direction the bats are going) {super extra hard?}

^ THIS ^ (Halbabica may have some help involving staying on walls......)

Ummm.......  Help?


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on March 13, 2010, 10:24:53 AM
Ask Hal for the code for going around corners.... your objectives are very different but I THINK it might help a LITTLE.

And I need help with destroying the object in my hands (I got this done) and then putting another object in my hands (IN MY HANDS is the important part)

I tried putting in stuff like scrHoldItem = .... or holdItem = 1; and EVERTHING and none of them worked... so HELP?


Title: Re: Game Maker Help Thread!
Post by: banna8 on March 13, 2010, 12:23:04 PM
change holditem.type to what you want to hold, that should work.


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on March 13, 2010, 12:27:24 PM
Can you tell me exactly what to put cause when I put holdItem.type = ___ it doesn't work


Title: Re: Game Maker Help Thread!
Post by: halibabica on March 13, 2010, 05:19:47 PM
Ask Hal for the code for going around corners....
I mimicked the requirements for crawling and ducktohang to make the ninja suit let you flip around edges.  Try looking at that and applying it to the worm.  It's in the Character Step Script thingy, not oPlayer1.


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on March 13, 2010, 09:29:28 PM
Can anybody tell me how to make a potion work?  I made the object like a jar and it works, but when I copy and paste codes in the scrUseItem, weird things start to happen... what do I have to add or take out from, say, the pistol code?

(I'm making it give me a life)


Title: Re: Game Maker Help Thread!
Post by: TailorTF on March 14, 2010, 01:32:32 AM
Do this:
Code:
else if (holdItem.type == "Potion")
       {
other.instance_destroy()
instance_create(x,y,oPoof)
global.plife += 1
}
This should destroy the potion,make a nice poof for effect,and add you one health.


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on March 14, 2010, 05:50:03 PM
I got it, with a different code, much longer.

I wanted to make oBloodBottle turn into (instance_place) a oBloodEmpty and with Hal's help, it works.

(I used global.bloodLevel += 8; )


How do I make the arrows for a bow go straight?  What variables do I change? I just want to change the bow code and NOT ARROW. (I made a crossbow and did not use scrFireBow for it cause I want no time for pulling back, I wanted it to fire like a gun)


Title: Re: Game Maker Help Thread!
Post by: hyperme on March 15, 2010, 01:43:01 PM
Dulpicate the bullet, change its damage to the arrow's, and use that.  I think that would be what you want.


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on March 15, 2010, 01:45:53 PM
How do I make the arrows for a bow go straight?  What variables do I change? I just want to change the bow code and NOT ARROW. (I made a crossbow and did not use scrFireBow for it cause I want no time for pulling back, I wanted it to fire like a gun)

In other words, how do I change the scrUseItem and NOT then oArrow code?

(Hyperme, trust me, I tried what you said before you said it, and that messes it up when you pick up arrows yourself and throw them)


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on March 15, 2010, 02:16:27 PM
How do I make the arrows for a bow go straight?  What variables do I change? I just want to change the bow code and NOT ARROW. (I made a crossbow and did not use scrFireBow for it cause I want no time for pulling back, I wanted it to fire like a gun)

In other words, how do I change the scrUseItem and NOT then oArrow code?

(Hyperme, trust me, I tried what you said before you said it, and that messes it up when you pick up arrows yourself and throw them)
Would adding a  if (holdItem.type == "Bow") Help?


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on March 15, 2010, 02:30:02 PM
*sigh

I'M NOT THAT STUPID! ;D
Ok, maybe I am....... but that's besides the point
Actually, it's not, but ANYWAY,

I did all that, but I copied and pasted the pistol code but the arrow falls instead of going straight.


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on March 15, 2010, 02:34:28 PM
*sigh

I'M NOT THAT STUPID! ;D
Ok, maybe I am....... but that's besides the point
Actually, it's not, but ANYWAY,

I did all that, but I copied and pasted the pistol code but the arrow falls instead of going straight.
arrow.yVel=-5 so it has some upward momentum ?


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on March 15, 2010, 02:35:13 PM
Um.............. I'll try that.......

(I tried putting oArrow.myGrav = 0;)


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on March 15, 2010, 02:36:51 PM
Um.............. I'll try that.......

(I tried putting oArrow.myGrav = 0;)
That won't help at all!


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on March 15, 2010, 02:39:53 PM
Neither did changing the yVel -= 5

What shall I do?


Title: Re: Game Maker Help Thread!
Post by: hyperme on March 15, 2010, 03:42:34 PM
Do my method, then when the arrow's velocity in both directions is zero, turn it into a regular arrow.


Title: Re: Game Maker Help Thread!
Post by: kinnik on March 15, 2010, 04:37:13 PM
Heya gummy buddy!  your problem may lay in the code of
objects->basic->oItem->line...  umm.. search for

else
{
       myGrav = 0.6;
}

then look up to see that it's nested in !collision solid, so ANYTHING that's not colliding with solid is being set to myGrav = 0.6   

if you comment this out and set the arrow's myGrav to 0 then arrows don't fall
 changing this may make bugs but maybe not??  I don't know why it's there.. seems kinda self defeating...


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on March 15, 2010, 07:50:30 PM
I tried putting oArrow.myGrav = 0; in the scrUseItem, but it did nothing........?

And guys, I made a new item called oBloodBottle, and I want it to work like a potion, I got the turning into oBloodEmpty part but now, the bug is, when you pick it up, the only way of getting rid of it is drinking it... as in you can't throw it or drop it by holding down and pressing X.  If you flip hang, though, you drop it

This happens only when I put the stuff in scrUseItem...


Title: Re: Game Maker Help Thread!
Post by: kinnik on March 15, 2010, 08:55:31 PM
the answer is in my post. it works, trust me.


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on March 15, 2010, 09:24:44 PM
Did you test it?
EDIT: I did it using your method, thanks!

(Where's the code for throwing things like rocks and jars?
Where's the code for collision of oPlayer1 with oExplosion?  I don't see it ANYWHERE)


Title: Re: Game Maker Help Thread!
Post by: Arucard on March 16, 2010, 08:17:19 AM
I don't know about throwing, but the explosion damage is in the step event of oPlayer1, the first code under //HURT, line 133.


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on March 17, 2010, 07:44:09 PM
Thanks, now...

Where is the code for throwing things like rocks and pots?
And where is the code for stuff like global.totalCrates?  It's not in scrClearGlobals


Title: Re: Game Maker Help Thread!
Post by: idoru on March 17, 2010, 08:55:33 PM
Where is the code for throwing things like rocks and pots?
And where is the code for stuff like global.totalCrates?  It's not in scrClearGlobals

I'm pretty sure there is no specific code for throwing rocks and pots. If you're looking for the code for a breaking pot, it's in the destruction code for pots.

As for the opened crates counter, it's in the read/write stats scripts. It gets initialized from the stats file, that's why it's not in the clear globals script. IIRC, it gets incremented in the action section of the step code for oPlayer1 when a crate is opened.


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on March 17, 2010, 09:01:23 PM
If there was no code for throwing a jar or rock, then how would the game know what to do?  And where's the stats script?

Where is the code for THROWING THINGS LIKE ROCKS?


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on March 17, 2010, 09:43:44 PM
If there was no code for throwing a jar or rock, then how would the game know what to do?  And where's the stats script?

Where is the code for THROWING THINGS LIKE ROCKS?
He was saying the code for throwing is the same for everything.

and why do you need it?


Title: Re: Game Maker Help Thread!
Post by: idoru on March 18, 2010, 06:07:54 AM
If there was no code for throwing a jar or rock, then how would the game know what to do?  And where's the stats script?

Where is the code for THROWING THINGS LIKE ROCKS?

The game knows what to do because it's an item. There's no special code for throwing a rock or jar; they both act the same. The code for throwing generic items that have no special code is at the end of scrUseItem. If you want something unique to happen when throwing rocks, etc., you'll have to add a new condition for it like there is for bombs, etc.

The stat tracking scripts are in the stat tracking folder. You could also find all usages of the crates opened variable by searching from the menu: Scripts > Search in Scripts and search for global.totalCrates.


Title: Re: Game Maker Help Thread!
Post by: Arucard on March 18, 2010, 10:24:44 AM
So does this mean simply making the object's parent oItem would make it able to be thrown? Meaning without any other coding, just adding a baseball or something with that parent object, and copying rock stats for instance.


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on March 18, 2010, 03:51:17 PM
So the throw code is in oPlayerStep or in oItem Step?

(I meant the code for throwing ANYTHING)


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on March 18, 2010, 04:19:51 PM
So does this mean simply making the object's parent oItem would make it able to be thrown? Meaning without any other coding, just adding a baseball or something with that parent object, and copying rock stats for instance.
More or less, yes. Well not quite.

Just copy the rock and change the sprite, it's the easiest way


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on March 18, 2010, 07:17:21 PM
I got it, and that's just NOT right.  It's a "potion".  I copied and pasted the jar and changed some stuff.  THen I copied and pasted stuff from oItem into scrUseItem and it worked


Title: Re: Game Maker Help Thread!
Post by: Arucard on March 19, 2010, 07:54:03 AM
Interesting, what exactly did you copy?


Title: Re: Game Maker Help Thread!
Post by: gummybears123 on March 19, 2010, 03:29:52 PM
I have no idea, I kept changing it.

Now it looks totally different.

Anyway, can't work on it today, too busy


Title: Re: Game Maker Help Thread!
Post by: halibabica on March 19, 2010, 09:50:12 PM
I am SO STUMPED.  Never before in any of the stuff I've done so far have I been this confounded.

I'm working on the ManTrap-shop-thingy for my mod, and I have everything working just right...except for one detail.  See, when you play as the Tunnel or Venus ManTraps, the sprite indexes of bomb and vine pickups change to match the color of the player.  But when I try to assign a variable from the pickup that had its sprite changed, it says the variable is unknown.  It's like changing the sprite wiped every variable from it!  I've tried tons of ways around the problem, but the only thing that worked was to create separate item pickups with different sprites.  I have no clue why this is happening at all!

I can try to elaborate more if you need me to, but this is really, REALLY weird and I am totally at a loss about it.

...help?


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on March 19, 2010, 10:48:05 PM
um... cheat and treat undefined variables as 0?


Title: Re: Game Maker Help Thread!
Post by: halibabica on March 20, 2010, 05:49:13 AM
Kinda hard when the undefined variable is the object's COST, mars.  :(

EDIT: I FINALLY found a work-around.  Since changing the sprite in the script caused it to lose its variables, I simply changed the sprite AFTER I got the variables I needed out of it.  Now it works just fine.  Thanks anyway, though!


Title: External Sounds
Post by: banna8 on March 21, 2010, 08:04:58 AM
How do I set up and call external sounds like in spelunky?


Title: Re: External Sounds
Post by: idoru on March 22, 2010, 06:45:15 PM
How do I set up and call external sounds like in spelunky?

First, the sound (for example, jump.wav) needs to be in the sound folder.

Then, you need to add something like this to oMusic:
global.sndJump = SS_LoadSound("sound/jump.wav", 0);

Then add a line like this to scrInit:
SS_SetSoundVol(global.sndJump, 2000 + 8000 * (global.soundVol/18));

Then call it like this:
playSound(global.sndJump);


Title: Re: Game Maker Help Thread!
Post by: ZeSandvich on March 24, 2010, 08:13:33 PM
Alright, I'm slightly new to GM, and I have this idea:
Reloading + Times
Alright, I'll use "add action button" for the reload, but this is an idea:
1) Reloading to full ammo - Obviously, when you press the "reload" button, after a specific time you will gain all the ammunition you can.
2) Adding 1 bullet per [time] seconds with a maximum - Alright, this may be a little bit trickier, but with this you will reload 1 bullet per [time] seconds up to a maximum of [number].


Title: Re: Game Maker Help Thread!
Post by: halibabica on March 27, 2010, 01:10:13 PM
I haz a problem!  Been a while since I had to ask for help, too...  :(

So, I've almost got the Stars Room Boss Rush working perfectly, but there's just 1 problem: Olmec.  Whenever I try to spawn him normally, the entire room disappears (player included!).  I tried creating a duplicate to spawn that didn't have Olmec's specifics (like his intro and stuff), but this caused him to disappear the moment he was spawned (leaving the rest of the room intact).  Finally, I changed the duplicate's parent object from "MovingSolid" to "none" and this made him work.  But he moved much slower than he used to, so I don't know what's up.

Is there any way to spawn him so he behaves like normal, but without causing weird things like the whole room disappearing to occur?


Title: Re: Game Maker Help Thread!
Post by: Kegluneq on March 27, 2010, 03:07:04 PM
Have you tried just a simple instance_create? Or is that the "spawn him normally"?


Title: Re: Game Maker Help Thread!
Post by: halibabica on March 27, 2010, 08:06:51 PM
Oh, derp, I figured out what was wrong.  Olmec's parent is MovingSolid, but MovingSolid's parent is oSolid, and the reason it worked when I made him have no parent was this:

00000000000000000000
00000000000000000000
00000000000000000000
000000009eee00000000
00000000eeee00000000
00000000eeee00000000
00000000eeee00000000
00000000000000000000
00000000000000000000
00000000000000000000
00eeeeeeeeeeeeeeee00

This is the layout for the Olmec fight in the Stars Room.  That '9' in the middle is where Olmec spawns, and those 'e's are there to make it so smoke puffs warn the player not to be underneath that spot when he appears.  But see how there are also 'e's along the bottom?  Yeah, the character 'e' is set to destroy any oSolid object that's underneath it.  Thus, Olmec was spawning and being destroyed by the 'e's that were on top of him.  I changed them to a meaningless character, and now he isn't removed the instant he's created.

Long story short: OlMeatmec works now.


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on March 27, 2010, 10:16:55 PM
glad to hear it, I thought it was something simple like that, but I couldn't figure out what was wrong!


Title: Re: Game Maker Help Thread!
Post by: Hayden on March 27, 2010, 10:26:32 PM
Just asking, I don't have plans to do this anytime soon, but I was wondering... If I was going to make a mod, what should I start with?

Like.. What is the most simple kind of mod to do, to get used to the coding language? I really don't understand one inch of that stuff. :(


Title: Re: Game Maker Help Thread!
Post by: Kirby on March 27, 2010, 10:28:24 PM
An editing mod. Just change what's already there.


Title: Re: Game Maker Help Thread!
Post by: Hayden on March 27, 2010, 10:36:20 PM
An editing mod. Just change what's already there.

Like, say, starting HP?

If so, I'll keep that in mind. :)

Thanks. :D


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on March 27, 2010, 10:42:33 PM
Can some one help? I really can't figure out how on earth to get man traps to shoot leaves at random times... I tranplated the mummies code and nothing!


Title: Re: Game Maker Help Thread!
Post by: Kegluneq on March 27, 2010, 10:47:18 PM
How would the mummy code help?


Title: Re: Game Maker Help Thread!
Post by: halibabica on March 28, 2010, 05:43:21 AM
You mean the mummy's code to barf flies everywhere?  Did you set the prerequisites correctly?  Most enemies don't behave totally randomly; they react to the player and the environment.  Also, at what step does the leaf-shooting fail?  Does it not even start?  Does it shoot them, but they just drift to the ground, or what?


Title: Re: Game Maker Help Thread!
Post by: idoru on March 28, 2010, 09:18:16 AM
Can some one help? I really can't figure out how on earth to get man traps to shoot leaves at random times... I tranplated the mummies code and nothing!

Here's some basic code. I've made it shoot a bullet, so you'll probably want to duplicate oBullet, change the sprite to a leaf, and make it shoot those. Also, you can easily add more bullets/leaves, randomize their velocity, etc. Anyway, add the following two lines somewhere in the create code for the mantrap:

SHOOT = 3;
ShootTrigger = rand(100,150);

Then in the step code, at the end of the code for the IDLE and WALK states (i.e. the blocks that start "if (status == IDLE)", etc.) add the two lines below. Make sure you add it to both states.

ShootTrigger -= 1;
if (ShootTrigger < 1) status = SHOOT;

That code will make the mantrap go into a SHOOT state from the IDLE and WALK states. So now you just need code for the SHOOT state. This is basic and you can add to it, but this works for basic functionality. It needs to be added to the step code in the state decision tree. I put it just before the block of code for STUNNED.

else if (status == SHOOT)
{
    if (facing == RIGHT)
    {
        obj = instance_create(x+17, y+8, oBullet);
        with obj
        {
            xVel = 3;
            yVel = 0.25;
        }
    }
    else
    {
        obj = instance_create(x-1, y+8, oBullet);
        with obj
        {
            xVel = -3;
            yVel = 0.25;
        }   
    }
    status = IDLE;
    counter = 40;
    xVel = 0;   
    ShootTrigger = rand(100,150);
    playSound(global.sndHit);   
}

ShootTrigger (at the end of the code above and in the create code) controls how long before the mantrap shoots. Choosing a smaller and larger number (for example rand(20,400)) will make the length more random. I've made the bullets sort of "fall" as they move away from the mantrap by setting the yVel to 0.25. You can set this to 0 if you want them to travel straight. Also, the xVel is only 3, since I figure leaves won't move too fast. If you want, you could set the xVel really high here, then have the step code of the "leaf bullet" decrease velocity over time so it slows down the further it gets from the mantrap. That would look pretty cool.


Title: Re: Game Maker Help Thread!
Post by: Necroscope on March 28, 2010, 11:43:49 AM
hello, Iam sorry if this is due to my own ineptitude but it seams every time i atempt to run the scource code in The Gamemakers program it come up with the following.

ERROR in
action number 1
of End Step Event
for object oScreen:

Error in code at line 2:
   surface_set_target(screen);
                      ^
at position 21: Unknown variable screen

This is then followed with.

ERROR in
action number 1
of Begin Step Event
for object oScreen:

Error in code at line 1:
   if (not surface_exists(pSurf)) pSurf = surface_create(screen_w, screen_h);
                         ^
at position 24: Unknown variable pSurf

The two alternate continueously.

I am using THe lite version of the sofware if it makes any difference.

Thank you.


Title: Re: Game Maker Help Thread!
Post by: Arucard on March 28, 2010, 11:55:41 AM
Most likely because of the Lite version.


Title: Re: Game Maker Help Thread!
Post by: Necroscope on March 28, 2010, 12:36:22 PM
Ok, thanks.  :(


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on March 28, 2010, 02:30:58 PM
You mean the mummy's code to barf flies everywhere?  Did you set the prerequisites correctly?  Most enemies don't behave totally randomly; they react to the player and the environment.  Also, at what step does the leaf-shooting fail?  Does it not even start?  Does it shoot them, but they just drift to the ground, or what?
Yes I know that, I put it on a random timer, and just... nothing happens. he acts just like a normal man trap


Title: Re: Game Maker Help Thread!
Post by: Kegluneq on March 28, 2010, 03:59:30 PM
@Necroscope:
You need GM Pro in order to make any use of the source.

I'm surprised you even got it to run at all with Lite.


Title: Re: Game Maker Help Thread!
Post by: Hayden on March 28, 2010, 04:36:40 PM
@Necroscope:
You need GM Pro in order to make any use of the source.

I'm surprised you even got it to run at all with Lite.

That explains why I got the same error as him. :D

Well I guess I have to get pro if I ever even plan on making a mod.
I may.. You never know. :)


Title: Re: Game Maker Help Thread!
Post by: ZeSandvich on March 29, 2010, 09:12:06 PM
So yeah, about my "reloading" question...


Title: Re: Game Maker Help Thread!
Post by: Kirby on April 01, 2010, 02:27:54 PM
I know it's been posted before,  but I cannot for the life of me find the post.

Where are ALL the messages that can appear at? I know they're in multiple objects and scripts, but I need all of them. The tutorial signs, the level feeling, Kali favor, ghost message, and the shop's messages.

Thanks.


Title: Re: Game Maker Help Thread!
Post by: Arucard on April 02, 2010, 12:53:15 PM
Tutorial signs= oMsgSign in 'blocks' object folder
Level feelings= alarm 0, 1 and possibly 4 of oPlayer1
Kali favor= scrGetFavor script
ghost= step event of oGame object
shops=items "you got..." messages in scrStealItem script
                  "A .... for $" in objects create event
                  "welcome to ...." and "you rolled..." in oShopkeeper step event
                  "Terrorist!" in scrShopkeeperAnger script
(I think that's all of them)


Title: Re: Game Maker Help Thread!
Post by: Damsel on April 02, 2010, 01:08:17 PM
Arucard helped me with all of those at one point or another in Spelunky as a Monkey. More details about changing words there.


Title: Re: Game Maker Help Thread!
Post by: halibabica on April 03, 2010, 10:22:50 AM
Okay, so, I'm trying to fix those wacky Thwomp traps so they can smash the player like a falling block or descending Smash Trap, but I don't know how or why it's not working as is.

Instead of what would logically be expected to happen, the Thwomp falls and stops when it hits the player.  I can make the collision fatal, but shouldn't it crash through the player and onto the floor instead?  I can't seem to get it to do that, and I don't know why!


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on April 03, 2010, 10:36:10 AM
Okay, so, I'm trying to fix those wacky Thwomp traps so they can smash the player like a falling block or descending Smash Trap, but I don't know how or why it's not working as is.

Instead of what would logically be expected to happen, the Thwomp falls and stops when it hits the player.  I can make the collision fatal, but shouldn't it crash through the player and onto the floor instead?  I can't seem to get it to do that, and I don't know why!
Well I know the game bugs out if oPlayer1 doesn't exist, even if hes dead.... thats what part of the issue


Title: Re: Game Maker Help Thread!
Post by: halibabica on April 03, 2010, 10:38:32 AM
But oPlayer1 can be crushed without being totally removed.  How do ya think Olmec works?


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on April 03, 2010, 10:49:04 AM
Oh right. duh.

how does he work?


Title: Re: Game Maker Help Thread!
Post by: halibabica on April 03, 2010, 10:57:35 AM
I have no friggin' clue.  But I found a way to make this work.  Now, if the Thwomp collides with the player while falling, it forces itself through them (y += #).  The end result is about what you'd expect.


Title: Re: Game Maker Help Thread!
Post by: hyperme on April 06, 2010, 12:57:36 PM
I need to know where all the scripts that effect the drawing of water/lava are and their names!  Please.


Title: Re: Game Maker Help Thread!
Post by: halibabica on April 06, 2010, 03:18:58 PM
If I recall, there were three places.  But even when I added oAcid to all of them, it still didn't work exactly right.  So I made it control its own sprite through its Step Event.

Code:
up = false;
upWater = false;
down = false;
left = false;
right = false;

if (collision_point(x, y-16, oWater, 0, 0)) { upWater = true; }
if (collision_point(x, y-16, oSolid, 0, 0)) { up = true; }
if (collision_point(x, y+16, oSolid, 0, 0)) { down = true; }

if (not up and not upWater)
{
sprite_index = sAcidTop;
}

This worked fine for me.

But the places that mention water and lava are...

scrInitLevel
scrCheckWaterTop
scrSetupWalls

If it's in any others, I'm unaware of it!


Title: Re: Game Maker Help Thread!
Post by: hyperme on April 07, 2010, 08:14:37 AM
Thanks.

Any way, new q!

How do i make things immune to the frozen zone?


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on April 07, 2010, 09:49:59 AM
Thanks.

Any way, new q!

How do i make things immune to the frozen zone?
I have been trying to figure this out...


Title: Re: Game Maker Help Thread!
Post by: Ambitious Sloth on April 07, 2010, 06:43:27 PM
Where is the code that determines the amount of items (bombs/ropes) you start with and where is the code that changes the values when one of the items is used?

Specifically I'm looking for how to change the global.bombs value beyond the scrClearGlobals script, and where I can change it after the user throws a bomb or rope.


Title: Re: Game Maker Help Thread!
Post by: idoru on April 07, 2010, 09:26:56 PM
Specifically I'm looking for how to change the global.bombs value beyond the scrClearGlobals script, and where I can change it after the user throws a bomb or rope.

The starting values for bombs and ropes are at the beginning of the step code for oPlayer1.

The code that decrements the values is also in the step code for oPlayer1, but is further down under the "Actions" header, about halfway through that block of code.


Title: Re: Game Maker Help Thread!
Post by: halibabica on April 08, 2010, 11:51:16 AM
How do i make things immune to the frozen zone?
The only things I've seen immune to the effects of the frozen zone are boulders, Olmec, and Thwomps.  Do you know what they all have in common?  That's right!  They're all moving solids!  And do you know where the game controls moving solids?  Why, in its Step Event, of course!

Somewhere in the scripts (I think it's the platform section), there's a script called 'scrGameStepEvent' or something like that.  That's used by oGame, which is present in every Spelunky level and controls things behind the scenes.  It can override the frozen zone, but I don't know how or why.

But I think I'd better warn you, too, that the frozen zone serves a very important purpose (beyond its obvious in-game benefits).  It keeps objects off-screen from moving around, which prevents them from causing lag.  If you add frozen zone immunity to too much stuff, the game will have a very difficult time running.


Title: Re: Game Maker Help Thread!
Post by: halibabica on April 09, 2010, 12:50:44 PM
Sorry, for the double post, but I have a semi-important question.

Error in function real().

Does anybody know what that means?  It happens when I try to load a level with text assigned to a ManTrap.  It's the only thing standing between me and NPC phrases for the level editor.  Any suggestions?


Nevermind, I figured it out.  We have NPCs now!


Title: Re: Game Maker Help Thread!
Post by: hyperme on April 10, 2010, 01:32:44 PM
How do I destroy a cretain object at a certain position?  In GML.


Title: Re: Game Maker Help Thread!
Post by: halibabica on April 11, 2010, 03:31:22 PM
Depends on where the object is.  I know for a fact the game can't destroy instances in the frozen zone.  What exactly are you trying to have destroyed?


Title: Re: Game Maker Help Thread!
Post by: hyperme on April 12, 2010, 07:37:29 AM
The last question doesn't matter no more.  I found another way to do the thing.

New question:

How do I set a varible to an object's name.


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on April 12, 2010, 09:49:11 AM
The last question doesn't matter no more.  I found another way to do the thing.

New question:

How do I set a variable to an object's name.
um... what?


Title: Re: Game Maker Help Thread!
Post by: hyperme on April 12, 2010, 09:54:22 AM
I'll explain my problem then.

I'm trying to make a Locked Chest be able to contain different items.  How would I set a varible in the Chest object to the name of another object that can be any item?


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on April 12, 2010, 09:56:15 AM
I'll explain my problem then.

I'm trying to make a Locked Chest be able to contain different items.  How would I set a varible in the Chest object to the name of another object that can be any item?
Why are you trying to do this?


Title: Re: Game Maker Help Thread!
Post by: hyperme on April 12, 2010, 09:58:15 AM
HOW IS THAT RELATED TO THE PROBLEM AT HAND?!

I mean, why do need to know that?


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on April 12, 2010, 09:59:15 AM
HOW IS THAT RELATED TO THE PROBLEM AT HAND?!

I mean, why do need to know that?
Because i can't help you if I don't know what the problem is and I still don't quite follow?


Title: Re: Game Maker Help Thread!
Post by: hyperme on April 12, 2010, 10:06:21 AM
In a script I want to set a varible in one object to the object name (like the Jetpack's object name is oJetpack) of another object.  And it has to be stored as text.


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on April 12, 2010, 10:10:27 AM
In a script I want to set a varible in one object to the object name (like the Jetpack's object name is oJetpack) of another object.  And it has to be stored as text.
Oh you want to put things in boxs in the level editor? yeah I don't know. halibabica knows I think...


Title: Re: Game Maker Help Thread!
Post by: halibabica on April 12, 2010, 01:46:53 PM
Oh you want to put things in boxs in the level editor? yeah I don't know. halibabica knows I think...
I sure does!

And the sad truth is...you CAN'T.  Oh, you can set a variable to equal an object with something like 'variable = instance_place(x, y, oWhatever)', but it sets it to that specific object, not the object name itself.  But that's okay, because it seems Derek had some foresight while making Spelunky!

First, you do like before and set a variable equal to the item in question.  Then you set a second variable for the chest.  I called mine 'holds'.  So you have 'variable = item' followed by 'holds = variable.type'.  The 'type' is the text in the item's create event that says what it is.  Then you set the chest to spawn that particular item when its variable 'holds' equals it.

For example:
chest = instance_create(oLockedChest)
(tracks the chest with the variable 'chest')
thing = instance_whatever(oBasketball)
('thing' now refers to oBasketball and all its variables)
chest.holds = thing.type
(the chest's variable 'holds' becomes oBasketball's variable 'type')

Then you set the chest to create a basketball when holds = "Basketball".

In fewer words, you can't set a variable to refer to a generic object.  However, if that object exists, you can set one variable to equal another of the object's, and use that to create a new object later.


Title: Re: Game Maker Help Thread!
Post by: hyperme on April 12, 2010, 02:33:08 PM
Thanks.  Now for most extreme if(inside = "Cake") statements.


Title: Re: Game Maker Help Thread!
Post by: TailorTF on April 17, 2010, 06:46:28 PM
Hey guys,can anybody help me?I need to find the code which creates the indestructable border around the level.I'm trying to make a mod,and I need plenty of space for it.
Also,does anybody know how to switch two creature's positions at once?I need a code for the creature and player swapping places.Sorry if I'm asking too much.


Title: Re: Game Maker Help Thread!
Post by: halibabica on April 18, 2010, 06:00:02 AM
I'm not sure where the level's border-drawing script is, but it's probably in the Level Generation folder somewhere.  And to make the player switch places with another creature, just do the following:

set variables to the player's x and y positions

px = oPlayer1.x
py = oPlayer1.y

then set variables to the creature's x and y the same way

cx = oCreature.x
cy = oCreature.y

Then just make their locations equal each other.

oPlayer1.x = cx
oPlayer1.y = cy

oCreature.x = px
oCreature.y = py

And poof, they swap.  Easy.  Unless some happens when the two of them collide, because one will always come a fraction of a second before the other (depending on the order of the scripts).

-----------------------------------------------------------------------------

I NEED HELP.

The pause screen glitch in TLS has me ripping my hair out.  I don't know what's going wrong!  Or, more accurately, WHERE it's going wrong.  To my understanding, these are the facts:

 - it only happens after the game has been paused once
 - it causes level generation scripts to be called inappropriately
 - it happens when you die in a custom level (but not when testing one)
 - it happens when you press F3 on the title screen
 - it DOESN'T happen in the previous 'finished' version of TLS

And that's all I know.  Something I changed between the previous release and this one is making it happen.  I haven't touched oScreen in a long time, though (which is the object that controls pausing).  I looked at the pause script, which is the same as it was in normal Spelunky, and the only thing I could find was the code that reactivates everything.  This suggests to me that...something...is getting activated that shouldn't be.  But I don't know where to look!

Does anyone have any clue about this?


NEVERMIND.  It turned out to be a crock of $h!+ bug.  >:(


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on April 18, 2010, 03:59:35 PM
Can some one help me make a bullet that fires at oPlayer1?


Title: Re: Game Maker Help Thread!
Post by: Kegluneq on April 25, 2010, 07:31:36 PM
Didn't I help you with this already? Or did it not work?


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on April 25, 2010, 07:46:06 PM
Yeah.. that didn't work..

not at all.


Title: Re: Game Maker Help Thread!
Post by: ipwnu1337 on April 26, 2010, 04:05:27 PM
How can I make an object have a maximum of ... lets say, 64 pixels of distance from an object?

I'm starting a fresh new project in gamemaker, and I'm attempting to make a ball & chain esque thingamabobber.  (It's top view)

Or, rather, how do I make one object follow another?


Title: Re: Game Maker Help Thread!
Post by: halibabica on April 26, 2010, 06:00:57 PM
Making one object follow another isn't hard; I did it with a few things in TLS (see Meatmec's eyes, Accuport, and of Spelunker's weapons).  What's tricky is making an object follow the player that applies resistance to his movement or has doesn't follow pixel for pixel (ie the ball 'n chain).

I'd look at the code for the ball itself.  The chain just follows a preset pattern for each link, but I have no idea how it actually works.


Title: Re: Game Maker Help Thread!
Post by: Sageofrage on May 08, 2010, 02:39:02 PM
i need a bit of help for my spelunky plus mod im making a new gamemode called "Tricks and traps" what code would i need to make a a blackhole AKA a point that sucks you in and kills you


Title: Re: Game Maker Help Thread!
Post by: Ambitious Sloth on May 10, 2010, 04:01:18 PM
How Do you change the walk/run speeds for the spelunker; I'm looking in the characterCreatEvent script but despite hours of of fiddling with variables nothing has changed to a noticeable effect where do I go to edit these values and what do they do exactly?


Title: Re: Game Maker Help Thread!
Post by: halibabica on May 12, 2010, 06:59:47 AM
@Mariofan09: Sorry for totally blowing off your question, but after thinking about it for a while, it's more complicated than I first thought!

@Ambitious Sloth: character movement is controlled by the script 'Character Step Event'.  Just about anything involving xVel regulates move speed there.


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on May 12, 2010, 09:57:36 AM
How Do you change the walk/run speeds for the spelunker; I'm looking in the characterCreatEvent script but despite hours of of fiddling with variables nothing has changed to a noticeable effect where do I go to edit these values and what do they do exactly?
There is a script I can't remember of the name of that sets it up, I'll find it when I get home.


Title: Re: Game Maker Help Thread!
Post by: Ambitious Sloth on May 12, 2010, 07:50:55 PM
Somebody should give mariofan09 some help, I personally don't know how to do such a thing; but, if instead you want to indulge my selfish nature, I have another question to ask:

How would I write the code to make something that would randomly create an object (lets say a rock) to fall from the ceiling or from a random point in empty space around the spelunker? For example:

I want to have debris falling at random times throughout a level, would I create an object that spawn more objects and follows the player, or would I have something that does the same but for the entire level despite the frozen zone?


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on May 12, 2010, 08:20:28 PM
i need a bit of help for my spelunky plus mod im making a new gamemode called "Tricks and traps" what code would i need to make a a blackhole AKA a point that sucks you in and kills you
Oh sorry, didn't see you there.

Let me put it this way.

Thats really hard.

Somebody should give mariofan09 some help, I personally don't know how to do such a thing; but, if instead you want to indulge my selfish nature, I have another question to ask:

How would I write the code to make something that would randomly create an object (lets say a rock) to fall from the ceiling or from a random point in empty space around the spelunker? For example:

I want to have debris falling at random times throughout a level, would I create an object that spawn more objects and follows the player, or would I have something that does the same but for the entire level despite the frozen zone?
Make blocks check to see if there is a space under then, and go on a timer if there is. When the timmer reaches 0, do a random chance 1 in X where x is a number you like if it is true then change into a rock, if not, then do nothing.



Title: Re: Game Maker Help Thread!
Post by: Sageofrage on May 12, 2010, 09:21:23 PM
i think i got it just really buggy im gonna try and fix it up before i release plus


Title: Re: Game Maker Help Thread!
Post by: hyperme on May 19, 2010, 02:52:53 PM
Where's the code for firing the bow for the Player?


Title: Re: Game Maker Help Thread!
Post by: halibabica on May 19, 2010, 05:22:41 PM
scrFireBow.  I think it's in the character folder of the script section.  It's referenced everywhere the player would've shot an arrow.


Title: Re: Game Maker Help Thread!
Post by: hyperme on May 20, 2010, 12:31:01 PM
More questions.

First, views.  How do I make them work!?  I'm trying to make a new room for various reasons but the views won't work right.  They just show the top corner of the room instead the area I set them to cover.
Second, how does the hogh score recording work for the minigames?


Title: Re: Game Maker Help Thread!
Post by: halibabica on May 20, 2010, 02:55:51 PM
In the object oScreen, there's a bit of script somewhere that sets the screen view for each of the game's rooms.  If you're adding a new room, you'll have to tack it on there with whatever specs you need.  I'd mimic something already there to make sure it works.

Also, minigame scores are all recorded under the same highscore.  They're added together in such a way that the game can break them down into their separate parts.  Since none of them can exceed 99, the game adds them this way:

game 1 = score1 x 10000
game 2 = score2 x 100
game 3 = score3

game 1 + game 2 + game 3 = minigame highscore total

So, if you had 35 in game 1, 75 in game 2, and 44 in game 3, it would produce the number 357,544 as the total highscore.  Then, when it needs to read those scores separately, it breaks them down in reverse and cuts off decimals.


Title: Re: Game Maker Help Thread!
Post by: hyperme on May 22, 2010, 02:46:14 PM
This doesn't work:

Code:
else if (status = ATTACK)
{
    bowpower +=1;
    if ( bowpower > 120)
    {
    if(facing = LEFT)
    {
    arrow = instance_create(x-14,y,oArrow);
    arrow.xVel = -4;
    arrow.yVel = 0;
    arrow.direction = 180;
    arrow.safe = true;
    arrow.alarm[2] = 10;
    playSound(global.sndArrowTrap);   
    status = RECOVER;     
    }
    else
    {
    arrow = instance_create(x+14,y,oArrow);
    arrow.xVel = 4;
    arrow.yVel = 0;
    arrow.direction = 0;
    arrow.safe = true;
    arrow.alarm[2] = 10;
    playSound(global.sndArrowTrap);
    status = RECOVER;     
    }}
}

How do I make it work?  For an enemy with a bow for a md I'm working on.


Title: Re: Game Maker Help Thread!
Post by: halibabica on May 23, 2010, 07:39:30 AM
You might want to take a look at how I handled the use of the bow for Spelunker in my mod.  It's not exactly the same as this, but it should give you the right idea.

Anyway, you should take out 'arrow.safe = true' because that means the player won't be hurt by it.  Likewise, alarm[2] on the arrow sets safe to false anyway, so you don't need that line either.

You also need to reset the bowpower variable to 0 after they fire so they can do it again.  Finally, 120 is about 4 seconds in real time, so the enemy's attack opportunity may have passed before they could fire.


Title: Re: Game Maker Help Thread!
Post by: hyperme on May 23, 2010, 09:09:31 AM
Thanks for the safe thing.  Turns out I added my code after a status check that set the enemy back to idle.  I feel silly.

Thanks for the help in answering my questions, Dude(tte)


Title: Re: Game Maker Help Thread!
Post by: halibabica on May 23, 2010, 03:16:42 PM
Dude(tte)
I a dude.  I know, my username's a little deceptive with that 'a' at the end.


Title: Re: Game Maker Help Thread!
Post by: grieck on May 27, 2010, 10:27:37 PM
Thanks for the safe thing.  Turns out I added my code after a status check that set the enemy back to idle.  I feel silly.

Thanks for the help in answering my questions, Dude(tte)

The only Dudettes here are Delgato232 and the aptly named Damsel.


Title: Re: Game Maker Help Thread!
Post by: Sudonimus on May 31, 2010, 02:09:57 PM
The only time (so far) where I've seen a dudette name end in an 'a' is mostly in the European circle.


Title: Re: Game Maker Help Thread!
Post by: TheTylor on June 01, 2010, 02:13:20 PM
I'm kinda new to this, but I'm competent enough to understand most of the code. I am struggling in locating a few specific portions of code I'd like to delete for my up-and-coming mod, however, and am thoroughly stumped as to where to find them. Any assistance would be most appreciated. The things I want to find and eliminate but still haven't been able to locate on my own are:

- The portion of the code that creates blood after the Spelunker takes damage from a long fall. I've been able to eliminate the blood creation from every other part of the Spelunker, and I even was able to remove the fall damage it self, but he still gets stunned and throws up some blood after a long fall. Help?
- When holding some items, like a pot, the item moves down a bit when the down key is pressed when he would normally be ducking. As I've removed ducking from my code already, it looks silly as the item still moves down slightly when the down key is pressed, but the player's sprite remains the same. Is there anyway I can remove this?
- The code that allows you to throw things like rocks and pots in multiple directions, as apposed to just straight forward.
- Lastly, and this is the trickiest as I belive it will require me to add some things as apposed to just taking stuff out; this mod has many situations in which you need to attack and kill Damsels. Damsels that are in their running state aren't phased by your attacks, they still spurt blood and take damage but they keep running. The same is true for stunned Damsels. Is there anyway I can make the Damsels behave more like the other humanoids (Cavemen, Hawkmen, Yetis, Shopkeepers) when attacked?

Thanks in advance, as I know this is asking a lot and you might not even be able to help me. Either way, thanks for at least reading!


Title: Re: Game Maker Help Thread!
Post by: Sudonimus on June 01, 2010, 04:13:30 PM
I been working on the Mudkip Mod lately, and I don't get something about the water gun.
When facing left, I want the water gun to shoot left.
When facing right, I want the water gun to shoot right.

Is it possible for it to be something like this?
Code:
if (facing right)
{
x += xVel
}
else if (facing left)
{
x -= xVel
}


Title: Re: Game Maker Help Thread!
Post by: halibabica on June 01, 2010, 09:21:00 PM
The player already has variables for the direction they're facing.  Look at the script where the pistol is fired and mimic that.


Title: Re: Game Maker Help Thread!
Post by: TheTylor on June 05, 2010, 06:51:23 PM
I'm kinda new to this, but I'm competent enough to understand most of the code. I am struggling in locating a few specific portions of code I'd like to delete for my up-and-coming mod, however, and am thoroughly stumped as to where to find them. Any assistance would be most appreciated. The things I want to find and eliminate but still haven't been able to locate on my own are:

- The portion of the code that creates blood after the Spelunker takes damage from a long fall. I've been able to eliminate the blood creation from every other part of the Spelunker, and I even was able to remove the fall damage it self, but he still gets stunned and throws up some blood after a long fall. Help?
- When holding some items, like a pot, the item moves down a bit when the down key is pressed when he would normally be ducking. As I've removed ducking from my code already, it looks silly as the item still moves down slightly when the down key is pressed, but the player's sprite remains the same. Is there anyway I can remove this?
- The code that allows you to throw things like rocks and pots in multiple directions, as apposed to just straight forward.
- Lastly, and this is the trickiest as I belive it will require me to add some things as apposed to just taking stuff out; this mod has many situations in which you need to attack and kill Damsels. Damsels that are in their running state aren't phased by your attacks, they still spurt blood and take damage but they keep running. The same is true for stunned Damsels. Is there anyway I can make the Damsels behave more like the other humanoids (Cavemen, Hawkmen, Yetis, Shopkeepers) when attacked?

Thanks in advance, as I know this is asking a lot and you might not even be able to help me. Either way, thanks for at least reading!

Can somebody help me? Surely someone knows where the first things are located in the code, at least.


Title: Re: Game Maker Help Thread!
Post by: halibabica on June 05, 2010, 07:52:10 PM
All right, let's see here...

1. Making the Spelunker stop bleeding should be fairly easy.  The script that creates blood only does so if object calling it is not 'bloodless'.  Everything that bleeds or can bleed has a 'bloodless' variable that, if true, prevents blood from appearing from it.  Setting the player character's bloodless to 'true' should stop them from bleeding.  There may be some places where enemies that AREN'T bloodless still cause the player to bleed, though.

2. I would guess it's somewhere in the player's draw event.  Look for item handling in the scripts there.

3. Somewhere in the player's step event (it could be the object itself or a script), there's a list of things that happen when the action button is pressed.  Find the part that pertains to throwing items and take out the bits for 'if up/down pressed'.

4. Pish-posh, this one's the easiest.  Just copy the effects of the whip on an enemy like a caveman and paste them over the current effects listed for Damsels.  You might need to add a new variable or two to the Damsel's create event, but that should do the trick.

I can only imagine why these changes are being made.


Title: Re: Game Maker Help Thread!
Post by: TheTylor on June 07, 2010, 09:08:32 PM
1. Ugh! I can't believe this was that simple! I don't know how I skipped over the "bloodless" variable in the source code; I knew enemies and such had it but never knew the Spelunker had it too. I mean, it makes sense now that I think about it. Thanks.

2. Nah, not that I could find. That was one of the first places I checked, but as far as I could see, it anywhere in there. :/

3. Thanks, again. I decided to keep this in, at least for this version, but it's nice to know that with your help I have found it and can remove it in the future if need be.

4. This half-way worked. I replaced "STUNNED" with "THROWN" in the caveman's source code that I copied into her collision with whip event, and that seems to be the same "state." Only problem is, the line "counter = stunTime" The Damsel doesn't have either of these variables, and I'm not 100% sure what they do or what I should set them to in the create event. I tried running it without that line, and it works good except it appears that the maiden continues to be hurt the entire time the whip is touching her without this line of code, killing her in one flick of the whip in a shower of blood. I'm guessing this line basically makes it so that she can't be hurt again for a short amount of time, but I'm not 100% sure and thought I'd better ask anyway.

Oh, and you'll see :D
very soon, perhaps, if all goes well.


I can only imagine why these changes are being made.


Title: Re: Game Maker Help Thread!
Post by: halibabica on June 08, 2010, 03:29:08 AM
Actually, the Damsel does have a variable called 'counter.'  It's a number that counts down when she (or anything else) is stunned.  When it hits zero, she wakes up and starts running again.  I don't remember what variable of hers is her maximum stun time, but you should be able to find it in her create event.  And yes, THROWN is equivalent to STUNNED for the Damsel.

Anyway, to solve her 1-hit KO problem with the whip, add a line of code in her collision with whip event that says 'whipped = true.'  Then set it so that she can only collide with the whip if 'not whipped.'  Finally, add an alarm timer that sets 'whipped' back to false, and you should be gold.  You may also want to make her immune while THROWN or counter > 0.

Oh, and after thinking about it, the code that makes items pop up and down while being held is probably in oItem's step event somewhere.


Title: Re: Game Maker Help Thread!
Post by: eyenot on June 25, 2010, 02:57:31 PM
I am completely new to Game Maker, but not to coding in general. I usually code in C. Something I would like to do for a mod to Spelunky, is make it so Spelunky doesn't save in the registry, saves and loads history in its own directory instead. Is this possible? Somebody mentioned a potential limitation of Game Maker. It would be really great to have this mod, Spelunky is already showing up at portableapps.com


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on June 25, 2010, 07:42:04 PM
I am completely new to Game Maker, but not to coding in general. I usually code in C. Something I would like to do for a mod to Spelunky, is make it so Spelunky doesn't save in the registry, saves and loads history in its own directory instead. Is this possible? Somebody mentioned a potential limitation of Game Maker. It would be really great to have this mod, Spelunky is already showing up at portableapps.com
Possible? yes. Hard? also yes.

The reason it saves there is because it's the easiest way to have game maker save only variables in a way that is hard to edit (most game make saves just take a screen shot of the game, useless here)


Title: Re: Game Maker Help Thread!
Post by: ipwnu1337 on July 01, 2010, 08:43:31 PM
Does anybody here have a clue on how to remove the limitation on the pressing of the attack button?  I've looked through the code quite a bit, but I can't find anything about it, really.  I'm looking for how to make it so the attack button can be held down to repeatedly do the action, as long as it is held down.


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on July 01, 2010, 09:04:31 PM
Does anybody here have a clue on how to remove the limitation on the pressing of the attack button?  I've looked through the code quite a bit, but I can't find anything about it, really.  I'm looking for how to make it so the attack button can be held down to repeatedly do the action, as long as it is held down.
It's not a matter of the code, it's a matter of how it's pressed. It's key press VS key hold. not sure how to code it, only how to drag and drop it honestly.


Title: Re: Game Maker Help Thread!
Post by: ipwnu1337 on July 01, 2010, 09:20:55 PM
Actually, I just got it to work!

It's a bit problematic for the picking-up and stuff, but it'll do.


Title: Re: Game Maker Help Thread!
Post by: Arucard on July 02, 2010, 07:11:31 AM
Not actually regarding Spelunky, but I wonder if anybody knows how to make text that types itself out (like in most RPGs) rather than just popping on screen. I've tried to look it up, but can't seem to get the right phrasing I guess.


Title: Re: Game Maker Help Thread!
Post by: halibabica on July 02, 2010, 07:25:26 AM
Text is usually handled by an event's Draw status, so you'd probably want to set a variable that gradually climbs in the step event that tells the Draw event how many letters to display in the message.  There's probably a more efficient way, but I don't know of any.


Title: Re: Game Maker Help Thread!
Post by: ipwnu1337 on July 02, 2010, 05:01:12 PM
And another question:

How do you get the game to only accept a command while a certain condition is active?

I'm trying to make it so the game only accepts the button being held down while an item is held.  When the item isn't held, it should act normally.

I've tried if (itemHold = 1), and several other conditionals but I'm not entirely sure how to get this done.


Title: Re: Game Maker Help Thread!
Post by: halibabica on July 02, 2010, 08:48:00 PM
You need to add a section to the hero's step event with conditions like:

if (holdItem.type = "yourItem" and (keyWhatevPressed or keyWhatevHeld))
{
stuff happens;
}

You may need to also add some code that checks to see when the button is pressed, held, and released.  It shouldn't be too difficult.


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on July 10, 2010, 08:13:58 PM
Meh. Having issues with custom made projectiles once more (for bad guys) including shoots that fire to targets, shoots that drop, not hitting durning exit phases and no matter how many times I try, I can get bad guys to shoot on a timer in spelunker.

I hate asking.. (I have done this 100 of times before in non-spelunky game maker games...) but I can't figure it out...

can I get some help?


Title: Re: Game Maker Help Thread!
Post by: halibabica on July 10, 2010, 08:40:33 PM
If you phrase your question in the form of anything anyone can understand, I can try to help.

If you don't want them shooting the player while they're exiting, just set the projectiles your using so that they don't affect the player while they're invincible.  Look at oBullet for reference.


Title: Re: Game Maker Help Thread!
Post by: TyrOvC on July 10, 2010, 09:23:30 PM
If by exit phases you mean when the projectile is created? create the instance out of the collision box, and if you have to to make it look good adjust the sprite/collision box to where just outside of the collision box is next to the gun barrel or whatever. Alternatively, you could use a short timer during which the projectile doesn't do anything.

For getting enemies to shoot on a timer, just have a frames_since_last_shot variable be raised by one at the end of every step. Since Spelunky by default runs at 30 frames per second, when the variable reaches 30 one second will have passed, etc., then you can set a can_shoot boolean to true. Then in whatever your doing for your shooting code, have it to check to see if can_shoot is true and if your other requirements for shooting (be has a straight collision line to the character or what have you), have the enemy shoot then set the can_shoot boolean to false, and the variable that keeps track of how many frames have passed since the last shot to 0.

For shoots that arc and are affected by gravity, use some algebra and the xVel yVel xVel yVel myGrav variables that are used for calculating all movement in the platform engine that Spelunky is built off of.

Just look at already present projectiles for reference. ;)  As far as I can tell everything you're asking is similarly done somewhere. 


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on July 11, 2010, 01:31:11 AM
I think you for the help, but um... that didn't really help. I know what to do, not how to do it.

I don't know how to use the the platform engine that spelunky was based off of honestly, other wise I could do this. Which is why I don't know how to make shoots that shoot at the player target, or get the timer working right.

 TyrannicalOverlordC By exit phase I mean going out the door.

I know how That works, but I couldn't seem to get it to work with out breaking the other code.


Title: Re: Game Maker Help Thread!
Post by: TyrOvC on July 11, 2010, 01:42:58 AM
Oh, you want enemies to aim at and shoot the player (or magical homing rockets, or bullet bills?)? If its the first, collision_line() and some angle detecting code is what your looking for (Are you trying to get enemies to aim and shoot arcing projectiles too? That would require some more effort and stuff that actual has to do with the base physics engine). I'll write up an example tomorrow if someone else doesn't get to it first (I need sleep now!).

As for the keeping objects whilst exiting a level, I have no idea. I just know some amount of stuff about the physics engine Spelunky is built off of because I used the same engine in a past game of mine. The only part that's specifically Spelunky that I've done any major amount of editing on is the editor.


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on July 11, 2010, 01:50:39 AM
I don't remember saying anything about arcing shoots... but I just want bullet to leave the gun going to the hero (which is not magic homing rocket or bullet bill, bullet bills just go left or right, I need 360 deggres)

and I know I need some angle detecting code. I just don't know how to um.. well code it.

And halibabica answered my door queston, it's cool, thanks.


Title: Re: Game Maker Help Thread!
Post by: TyrOvC on July 13, 2010, 12:34:42 AM
Sorry about not answering yesterday!  I was driving across two states and didn't feel like searching for an open wireless signal.

Code:
//360 degree shooting code
//Put in create event of instance, or, you could have the enemy firing the projectile set the projectile's yVel and xVel variables itself.

dir=point_direction(x,y,oPlayer1.x,oPlayer1.y); //may have to adjust these based on the sprite's origin
yVel=-2*sin(degtorad(dir)); //replace 2 with how many pixels you want it to move per frame, keep sign negative!
xVel=2*cos(degtorad(dir)); //replace 2 with how many pixels you want it to move per frame, keep sign positive!
//Play with these values if you want the projectile to speed up or speed down
yAcc=0;
xAcc=0;

//In oProjectiles step event
yVel+=yAcc; //you might also want to add a hard limit to how high the velocity can go
xVel+=xAcc;
x+=xVel;
        y+=yVel;
//End

Also, you can use:
Code:
collision_line(x,y,oPlayer1.x,oPlayer1.y,oSolid,0,1)<=-1 //may have to adjust these based on the sprite's origin
to check and see whether there is a wall in the way  before the enemy shoots, if you want them to be semi-intelligent in that regard


I'm coming up with some of this off the top of my head, so let me know if you have any questions/it doesn't work.


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on July 13, 2010, 11:05:18 AM
I guess... I'll make missiles as well then..

(I just wanted normal bullets that go in one way and keep going until they hit something,,, which I had a poorly made work around right now, but a better one would be nice)


Title: Re: Game Maker Help Thread!
Post by: TyrOvC on July 13, 2010, 11:24:55 AM
Well, you can use it for shooting normal bullets in 360 degrees.

If
Code:
  dir=point_direction(x,y,oPlayer1.x,oPlayer1.y); //may have to adjust these based on the sprite's origin
   yVel=-2*sin(degtorad(dir)); //replace 2 with how many pixels you want it to move per frame, keep sign negative!
   xVel=2*cos(degtorad(dir)); //replace 2 with how many pixels you want it to move per frame, keep sign positive
is only ran once, like in the bullet's create event, it should be on a set direction until it hits something. You don't actually have to use the acceleration bit, that was just something extra.


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on July 13, 2010, 01:42:53 PM
Ok thanks a lot.

Now.. he he he.. the new foe should be ready. (with mostly somewhat new AI!)


Title: Re: Game Maker Help Thread!
Post by: Yknuleps II on July 20, 2010, 07:23:39 AM
Can you please tell me:
1.Which is the variable that indicates spelunky's reloading rate?
2.Which is the variable that indicates spelunky's health?
3.Which is the variable that indicates spelunky's weapon?
4.Which is the variable that indicates that spelunky has killed a shopkeeper?
5.Where is the code which decides what type shall be the next toom?
6.What is the difference between items and collectables folders?
Thanks in advance ^.^


Title: Re: Game Maker Help Thread!
Post by: Arucard on July 21, 2010, 09:26:33 AM
Can you please tell me:
1.Which is the variable that indicates spelunky's reloading rate?
Assuming you mean for the pistol and sgun; firing,firingMax, firingPistolMax, and firingShotgunMax. all set in the create event of the player object.
2.Which is the variable that indicates spelunky's health?
global.plife which I guess is set in the first code block of the step event. I don't see it being initialized anywhere else.
3.Which is the variable that indicates spelunky's weapon?
all over, mainly the action portion of oPlayer1's step event (again) but there' the hold item script and a lot of other factors since anything can be a weapon.
4.Which is the variable that indicates that spelunky has killed a shopkeeper?
global.murderer
5.Where is the code which decides what type shall be the next toom?
step event of oTransition
6.What is the difference between items and collectables folders?
Items includes most anything you can pick up and throw around, like rocks, Idols, even the ball and chain. The collectibles are things that are picked up automatically, like gold and gems, and things added to the HUD, like the cape or bombs/ropes.....and bone piles for some reason?
Welcome.
Yes.


Title: Re: Game Maker Help Thread!
Post by: Yknuleps II on July 22, 2010, 12:35:11 AM
I'm now ready to start working on my spelunkyshteh mod ;)


Title: Re: Game Maker Help Thread!
Post by: Kirby on July 23, 2010, 05:15:21 PM
How would I go about replacing the whip with a machete.

IE when you press X it shows the machete attack, but you can still pick up other items.


EDIT: Also is it possible to make an animation only play once?


Title: Re: Game Maker Help Thread!
Post by: halibabica on July 24, 2010, 05:31:04 AM
To replace the whip with the machete, go to the Step Event of oPlayer1.  Under the Action section, you should find a place where it creates oSlash if the player presses x while holding the machete.  Move this code further down and put in place of where it creates oWhip and oWhipPre, and that will make the Spelunker swing a machete by default instead.


Title: Re: Game Maker Help Thread!
Post by: Kirby on July 24, 2010, 11:12:34 AM
Thanks.

I'm trying my hand at making a mod again, so this is useful info.


Title: Re: Game Maker Help Thread!
Post by: Arucard on July 25, 2010, 09:25:53 AM
Or you could simply replace the whip sprites with the machete instead. You can also shorten the animated sprites (i.e. take some out) to shorten the animation itself, they will play only once by default though.


Title: Re: Game Maker Help Thread!
Post by: kinnik on August 16, 2010, 06:41:44 PM
PLEASE HELP!  I'm making a new enemy and I need to adjust it's collision area.  I've tried everything i can think of:

-changing the GM sprite collision box for ALL animations
-changing the Yu built setCollisionBounds(left,up,right,down)


It's a cobra that bits when a player get within 14 pixels from it. When it bits it uses a 32*16 size animation and it increases it's collision boundary temporarily.

it is now working for biting to the left with:
setCollisionBounds(2,0,14,16);

but when it bits to the right it doesn't collide...
i've tried (2,0,32,16) and a bunch of others.

ANY SUGGESTIONS?  pleease...   :-*


Edit: Finally got it. It does use GM's built in collision but it doesn't flip the collision mask around in Yu's code.  Soo, I just overloaded the draw event from oEnemy with oCobra's draw event and when the cobra's attacking it doesn't flip the sprite, it uses a different sCobraAttackRIGHT animation...  There must be a better way. Anyone?


Title: Re: Game Maker Help Thread!
Post by: Thespis on August 29, 2010, 10:32:16 PM
Kinnik, could you show me your source so I can look at it for you? A hands on approach is the only way I know to solve things, but if I can help you I'll certainly explain what I did. I recently had a similar problem creating a oPlayer2: when I picked up a gun, I would shoot fine to the left, but would shoot myself when I faced the right. I think my problem was caused by a scripting error concerning aligning variables correctly to oPlayer2, so that wouldn't help you too much, but I could try to help you regardless.


Title: Re: Game Maker Help Thread!
Post by: kinnik on August 30, 2010, 02:04:57 PM
Thanks Thespis!  I did already figure it out..  It was both due to the collision mask not being reversed in the "face left or right" code in the draw event (solved as above)  AND to do with the limited collision range dictated by the first 'if' statement in the oEnemy collision with oCharacter event. (It limited the distance the player must be away from the enemy for collision to occur)  It might be interesting to use this 'if' to dictate a 'near miss' or partial hit... like, collision occurred but was not enough for a full hit.  ;)


Title: Re: Game Maker Help Thread!
Post by: Thespis on August 30, 2010, 03:59:40 PM
Wow! Nice work there! Could velocity come into play on those near miss situations? Like, if the speed of the moving image for the oCobra attack wasn't high enough then oCobra just bounces off?


Title: Re: Game Maker Help Thread!
Post by: kinnik on August 30, 2010, 06:26:31 PM
Sure.. but in the instance of the cobra, it doesn't move from it's spot (just changes the animation). So that would not be applicable to it.  But, it could do for enemies that change velocity. (i donno any tho, maybe Frogs?)


Title: Re: Game Maker Help Thread!
Post by: hyperme on September 18, 2010, 01:39:41 PM
How do I stop Tunnel Man from breaking a Room to bits with his mattock?  Such as similar to the Bonus Challenge Rooms.


Title: Re: Game Maker Help Thread!
Post by: halibabica on September 20, 2010, 12:04:36 PM
Depending on what room it is, find the object that regulates it (like oTitle for the title screen, oSunRoom for the sun room, etc).  Then, in its create event, add:

with oSolid
{invincible = true;}

That will make all the solid objects present indestructable, even to explosions.


Title: Re: Game Maker Help Thread!
Post by: ATP on October 18, 2010, 05:26:15 PM
How do I make a new variable in GML? It says I just need to name it and assign a value, but when I try to do so, I get this error message:
Quote
___________________________________________
ERROR in
action number 3
of  Step Event
for object oBluealien:

Error in code at line 17:
           global.bluealiens += 1;
           ^
at position 10: Unknown variable bluealiens

(The coding is for a modified and recolored Alien that I got ingame by copying the coding for randomly generating snakes.)




Title: Re: Game Maker Help Thread!
Post by: Moloch on October 18, 2010, 06:11:25 PM
Try adding global.bluealiens = 0 to the oGlobals object (Create event).


Title: Re: Game Maker Help Thread!
Post by: ATP on October 18, 2010, 07:10:03 PM
Where in the code should I add it? EDIT: I'm using the TLS source code. Does that make a difference?


Title: Re: Game Maker Help Thread!
Post by: Arucard on October 19, 2010, 07:43:27 AM
I don't think it should matter, but you can add it to the top to make it easier to get to if you need it.


Title: Re: Game Maker Help Thread!
Post by: ATP on October 20, 2010, 04:08:34 PM
Thanks.


Title: Re: Game Maker Help Thread!
Post by: Moloch on October 20, 2010, 06:30:05 PM
Just to correct myself, I wanted to tell you to put it in the scrClearGlobals script (you will see all the other globals initialized there) but I didn't have access to the source at the time. In this case it probably doesn't matter, since scrClearGlobals is called by oGlobals when the game starts. If you add any other new globals to the game, put them in scrClearGlobals so they get reset when the player dies and starts a new game.


Title: Re: Game Maker Help Thread!
Post by: ATP on October 21, 2010, 06:25:24 PM
OK, now that I've gotten the enemy to work properly, how do I make the stat file record kills for it?


Title: Re: Game Maker Help Thread!
Post by: Moloch on October 22, 2010, 11:51:04 AM
I was hoping you wouldn't ask that. :) I'll tell you were to look and hope you can figure the rest out. In scrReadStats you need to increase the size of the global.enemyDeaths and global.enemyKills arrays by 1 (there are initialized in the FOR loops at the top). The stats for your new enemy will probably now be global.enemyDeaths[25] and global.enemyKills[23]. Set the FOR loops further down that read the file to read that extra slot too. You should also change the filename used for the stats file, or else things will be messed up when reading/writing to the 'official' TLS stats format.
Then add your new enemy entry to the enemy kills and enemy deaths lists in scrWriteStats.

In oEnemy (Collision with oCharacter event) you'll see where the stats are changed when the player dies from touching an enemy.

In your new enemy object (Step event) you'll see where the global.enemyKills is changed when the enemy dies.


Title: Re: Game Maker Help Thread!
Post by: halibabica on October 22, 2010, 11:55:40 AM
You may actually have an easier time adding a separate global variable for the kills and deaths by this new enemy.  Take a look at how I added Spelunker and Tunnel Man to the stats files for reference.  You'll still have to look in the same places Molok said, though.


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on October 27, 2010, 09:57:07 PM
I know this should be easy, but it keeps gliching out somehow so yeah..I hate having to ask this but:

How do you make ladders show up on the title screen as you unlock shortcuts?


Title: Re: Game Maker Help Thread!
Post by: halibabica on October 28, 2010, 04:09:05 AM
In the oTitle object's Create event, it places ladder parts and doors on the title screen depending on how many shortcuts you've unlocked.  If you want them to be permanent, you can add them to the room yourself.  If you want the title screen to to spawn them under specific requirements, add them to the Create event with your prerequisites.


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on October 28, 2010, 08:39:07 AM
In the oTitle object's Create event, it places ladder parts and doors on the title screen depending on how many shortcuts you've unlocked.  If you want them to be permanent, you can add them to the room yourself.  If you want the title screen to to spawn them under specific requirements, add them to the Create event with your prerequisites.
Yeah thats the part I know. I am just wondering what variables they save the shortcuts under...


Title: Re: Game Maker Help Thread!
Post by: halibabica on October 28, 2010, 02:12:14 PM
Shortcuts are saved as part of a high score, actually.  I've never really been clear on how that works.  The best advice I can offer is to look at what Derek did to make the shortcut doors appear and do something similar.


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on October 28, 2010, 06:36:27 PM
Shortcuts are saved as part of a high score, actually.  I've never really been clear on how that works.  The best advice I can offer is to look at what Derek did to make the shortcut doors appear and do something similar.
Yeah thats what stoped me from working on gates for a month..

I'll keep trying


Title: Re: Game Maker Help Thread!
Post by: Sparkle on October 30, 2010, 08:49:32 PM
UGH. Stupid Game maker having it's requirements for PRO. Seriously, I can't even run my executable without needing PRO. I wish I had 25 dollars, and I had a way to use it on the internet this sucks.

Anyways, yeah. I'm an uber noob alright, I've been reading the code and looking at things for an hour, and all I've done is add a new sprite, and figure out that rooms are 40x32 and there are 16 10x8's.
and i know this isn't really a question, I'm just saying.
But I do have a question, how exactly did Derek make it so that each area, except the last has 4 levels, or is that in the scrRoomGen* code? Sorry, the whole code confuses me :x


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on October 31, 2010, 12:37:42 AM
UGH. Stupid Game maker having it's requirements for PRO. Seriously, I can't even run my executable without needing PRO. I wish I had 25 dollars, and I had a way to use it on the internet this sucks.

Anyways, yeah. I'm an uber noob alright, I've been reading the code and looking at things for an hour, and all I've done is add a new sprite, and figure out that rooms are 40x32 and there are 16 10x8's.
and i know this isn't really a question, I'm just saying.
But I do have a question, how exactly did Derek make it so that each area, except the last has 4 levels, or is that in the scrRoomGen* code? Sorry, the whole code confuses me :x
... this mod might be to much for you.

just.. mod the bad guys for now.


Title: Re: Game Maker Help Thread!
Post by: halibabica on October 31, 2010, 06:55:19 AM
Please phrase your question in the form of...a question?  What were you trying to ask?

And, yes, you'll need GM Pro to do just about anything with Spelunky.


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on October 31, 2010, 09:59:01 AM
Please phrase your question in the form of...a question?  What were you trying to ask?

And, yes, you'll need GM Pro to do just about anything with Spelunky.
his question is basically: how do I add a new area?


Title: Re: Game Maker Help Thread!
Post by: Sparkle on October 31, 2010, 10:13:36 AM
okay, I'll try to do some tonight. thanks Mars, and Hali. and I did have a questionmark in there somewhere.


Title: Re: Game Maker Help Thread!
Post by: Arucard on November 01, 2010, 09:21:23 PM
Please phrase your question in the form of...a question?  What were you trying to ask?

And, yes, you'll need GM Pro to do just about anything with Spelunky.
his question is basically: how do I add a new area?
And how to get that area to recur for four levels before moving to a different area.


Title: Re: Game Maker Help Thread!
Post by: Sparkle on November 03, 2010, 03:35:32 PM
Yeahh, I forgot to save my work while working on my Mod for Spelunky in Game maker.
So I need help to unfreeze it, so I can save my work.
Anyone know how to unfreeze Game Maker?

P.S. no, messing with the priority of it in Task manager doesn't work apparently (even though that's what I have to do for every other program to make it run more smoothly and not freeze or to get it to unfreeze.)

EDIT: Oh well. I closed it. I figured I was just wasting time. But still, if anyone knows how, it would be nice to know (because that's the second time it froze on me like that)


Title: Re: Game Maker Help Thread!
Post by: halibabica on November 03, 2010, 06:02:53 PM
As far as I know, there's no way to unfreeze it.  It only seems to happen when I'm editing sprites, so I always save my progress before I do any sprite work.  You'd be well advised to do the same.


Title: Re: Game Maker Help Thread!
Post by: Sparkle on November 03, 2010, 07:10:44 PM
Yeah, I started saving after every sprite I edited, because the last time it happened, I had to reedit like 15 sprites. (bats, spiders etc.)


Title: Re: Game Maker Help Thread!
Post by: Moloch on November 03, 2010, 07:16:19 PM
GM backs up your file every so often (or only when you test? I'm not sure), so check your save folder for .gb1, gb2, etc. files.


Title: Re: Game Maker Help Thread!
Post by: Sparkle on November 03, 2010, 08:27:07 PM
Oh well. thanks, I found a "gb.1" that was somewhere around The time that it crashed, but It's alright... this time at least, because I already redid all the sprites and even more, so no harm done, just time wasted. But thanks for the little tidbit, it will probably be helpful i the future


Title: Re: Game Maker Help Thread!
Post by: hyperme on November 04, 2010, 02:23:27 PM
Where be the code that controls the Moai Head's forced spawning?  Line numbers are welcome.  As in needed.  Please.


Title: Re: Game Maker Help Thread!
Post by: halibabica on November 04, 2010, 07:44:51 PM
Where be the Moai's forced spawning?
scrLevelGen, line 212. 8)


Title: Re: Game Maker Help Thread!
Post by: ManaUser on November 06, 2010, 12:08:12 PM
What's the most practical way to copy an Object from one GM project to another? (e.g. from TLS to a new mod, or whatever) I understand other scripts often have to be edited as well to make things work, I'm just talking about the object itself. Game Maker's Export Resources function seems pretty useless.


Title: Re: Game Maker Help Thread!
Post by: halibabica on November 06, 2010, 03:48:17 PM
To my knowledge, there's no way to bring an object directly from one place to another.  You'll just have to recreate the object in the new mod exactly as it is in the previous one.  Get sprites, parents, depth, and all event scripts in the right place and it should work.  If it doesn't, then there may be other related objects that you'll need to change.


Title: Re: Game Maker Help Thread!
Post by: ManaUser on November 06, 2010, 04:34:27 PM
Bleh. Seems like a rather serious shortcoming in Game Maker. Oh well, I guess doing manually isn't that bad. Thanks anyway, now I can stop looking for a way to do it. :P


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on November 06, 2010, 08:13:32 PM
To my knowledge, there's no way to bring an object directly from one place to another.  You'll just have to recreate the object in the new mod exactly as it is in the previous one.  Get sprites, parents, depth, and all event scripts in the right place and it should work.  If it doesn't, then there may be other related objects that you'll need to change.
Not QUITE true! there is a way! frist you take the game you want the object from, then you get ride of EVERYTHING but the object and it's sprites, and you mix the two games together!

so basicly not true


Title: Re: Game Maker Help Thread!
Post by: ManaUser on November 06, 2010, 09:28:12 PM
Not QUITE true! there is a way! frist you take the game you want the object from, then you get ride of EVERYTHING but the object and it's sprites, and you mix the two games together!

so basicly not true
I tried that, but it's kind of a pain--at best--because if you do that the object you're trying to export loses collision events, its sprite and so on, because all those things have been deleted. Plus import and export take ages and ages for a project as complex as Spelunky. So sure, it's technically possible, but I came to the conclusion that it was more work than just recreating the object manually.

I don't fully understand why they couldn't make a simple "save this object"/"load object" type system. But I suspect it has something to do with their weird system of using numeric object indices.


Title: Re: Game Maker Help Thread!
Post by: Arucard on November 08, 2010, 05:44:45 AM
But 'save as' should render that problem obsolete. It should be possible to drag and drop with two of windows open too.


Title: Re: Game Maker Help Thread!
Post by: Damsel on November 10, 2010, 08:54:26 PM
Hey guys.

In this mod I am making, I wan to turn off the spelunker giving blood when he dies.

You know how?


Title: Re: Game Maker Help Thread!
Post by: halibabica on November 10, 2010, 08:57:06 PM
Go to oPlayer1's Create event and look for a line that says 'bloodless = false'.  Change it to 'true' and he should stop bleeding.

If that doesn't work, then you may need to do something more complicated.


Title: Re: Game Maker Help Thread!
Post by: Damsel on November 13, 2010, 02:56:15 PM
Hey. It's me again. In a different mod I am thinking about working more on, the main character is stuck underground when I run. Last time I fixed it, but I can't remember how. Any ideas?

EDIT: The bloodless=true worked.

EDIT: Oh, wonderful. NOW I got myself all confused while attempting to turn off the blood sprite for spikes. That would be easy, but I still want ti to show for when a baddie lands on the spikes. Help would be appreciated.


Title: Re: Game Maker Help Thread!
Post by: halibabica on November 13, 2010, 04:43:29 PM
Stuck underground?  Does the sprite just appear halfway in the ground, but you can still move like normal?  If so, go to the run sprite you're using for the Spelunker and set it to be drawn from the middle (8,8) instead of the top corner (0,0).

Also, to stop the player from bloodying spikes, look in the Hurt section of oPlayer1's Step event.  Somewhere in there is the section that handles spike collisions.  Just take out the part that makes the spikes change sprites.


Title: Re: Game Maker Help Thread!
Post by: Damsel on November 13, 2010, 05:04:24 PM
(http://i54.tinypic.com/28jy3ar.jpg)


Title: I'm not positive this goes here.....
Post by: banna8 on November 14, 2010, 06:00:29 PM
My friend and I are just beginning a rayman-esque project. We are planning on having each part as a seperate object so they can be sprited and manipulated individually. Does anybody have ideas as to how we should go about this? In particular if the feet should move dependent on the body? should collisions with the ground be handled by the feet or the body? etc...

Here's Rayman for the uninformed, arms legs don't exist, his hands, feet, head and body are entirely seperate.

(http://www.naggynerd.com/wp-content/uploads/2010/06/rayman-origins.png)


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on November 18, 2010, 01:28:59 AM
Yes. make the body have a mask and do all the hard work (so it's mask goes down to the feet) and have the feet be objects that just follow the body and move when you walk.


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on November 28, 2010, 08:53:32 PM
so yeah

Wanting to make a it when you jump of a frog you bounch.

with out sending you into a wall would help


Title: Re: Game Maker Help Thread!
Post by: halibabica on November 29, 2010, 01:48:10 PM
Uh...what?  You mean you want the player to bounce high off of frogs?  Give the Frog its own collision with player event and increase the yVel with which the player bounces.


Title: Re: Game Maker Help Thread!
Post by: zetsu on December 02, 2010, 01:24:59 PM
Is there a way to search through all the code in game maker without individually opening every single piece of code and using the search function?


Title: Re: Game Maker Help Thread!
Post by: halibabica on December 02, 2010, 04:45:31 PM
Under 'Scripts' select 'Search in Scripts' and type in what you want to find.  This will find what you typed in any of Spelunky's scripts and list them out for you.  Unfortunately, it doesn't search through objects.


Title: Re: Game Maker Help Thread!
Post by: Moloch on December 02, 2010, 07:22:46 PM
To search through objects you can select 'Show Object Information' from the Edit menu (this will list the code of every object..Spelunky has a lot of objects so you will probably have to wait several seconds), then you can save it to a text file and search that with your favorite text editor.  If anyone knows of an easier way, please post it.


Title: Re: Game Maker Help Thread!
Post by: zetsu on December 03, 2010, 09:29:35 AM
Do you know how the control keys are loaded, and if you do where the code is for it?
I know that they're set with the config program but i don't know where the code is that writes the controls.


Title: Re: Game Maker Help Thread!
Post by: Moloch on December 03, 2010, 11:26:39 AM
Do you know how the control keys are loaded, and if you do where the code is for it?
I know that they're set with the config program but i don't know where the code is that writes the controls.

For the config program the keys.cfg and gamepad.cfg are written in oKeyConfig/oJoyConfig 'Room End' events.

For Spelunky all the settings/controls are loaded by scrInit.


Title: Re: Game Maker Help Thread!
Post by: zetsu on December 03, 2010, 02:59:41 PM
Sorry to keep bothering you but what is global?
I see it referenced a lot but i'm not familiar with GameMaker.

{
  if (global.joyStartVal > 0)
}
||
{
  if (global.isDamsel)
}

things like those


Title: Re: Game Maker Help Thread!
Post by: ManaUser on December 03, 2010, 04:00:15 PM
Essentially global is a fake object used to store global variables, meaning you can access global.isDamsel from any script or event code.


Title: Re: Game Maker Help Thread!
Post by: zetsu on December 03, 2010, 04:35:34 PM
oh so { global.isDamsel } would return a boolean value named isDamsel?


Title: Re: Game Maker Help Thread!
Post by: Moloch on December 03, 2010, 06:12:42 PM
A normal (local) variable is assigned to a particular object/instance, like how each enemy has a hp variable of their own to keep track of their health. When that enemy is destroyed, all its variables are gone.
When you finish a level and go to the next one, (nearly) everything in the old room (including the player) is destroyed, then in the next room a new player is created at the start position. So to keep track of things like player health, money, etc from level to level they are stored in global.plife, global.money, global.bombs, etc.

oh so { global.isDamsel } would return a boolean value named isDamsel?

global.isDamsel will return a boolean value. It doesn't return another variable just named isDamsel if that's what you mean. The 'global.' in front of it just means that you can change/reference it from anywhere in the game. That's why all the keyboard/gamepad keys are stored in globals like global.joyStartVal when the game is started, otherwise you would have to do something like load the .cfg files again every time you went to another room (or use a persistent object - but don't worry about that).


Title: Re: Game Maker Help Thread!
Post by: zetsu on December 03, 2010, 06:31:15 PM
so
{
  stringy = file_text_open_read("keys.cfg");
  if (file)
  {
    global.keyUpVal = real(file_text_read_string(stringy));
         file_text_readln(stringy);
  }
}

says to the compiler
{
1. assign stringy to a string that is what is contained in the file "keys.cfg";
2. if stringy isn't an empty string then;
  2-1. assign the variable in the "global" object with the name "keyUpVal" to the
         character associated with the ascii value found that is equals to the
         parsed int of the first string on the first line of stringy;
  2-2. go to the next line of stringy;
}
or something similar?

I know a tiny bit of Java so would it be similar to using the Scanner object in java?


Title: Re: Game Maker Help Thread!
Post by: Moloch on December 03, 2010, 08:51:03 PM
Yep. But "if (file)" should say "if (stringy)".

(I don't know any Java)


Title: Re: Game Maker Help Thread!
Post by: zetsu on December 03, 2010, 10:01:47 PM
That's what i meant but i changed the names from the actual code so it wouldn't be as confusing when i referenced the variable "file" as opposed to the file "keys.cfg".

thanks for the help. I'll probably have some more questions later.


Title: Re: Game Maker Help Thread!
Post by: zetsu on December 06, 2010, 09:45:13 AM
How does the program tell the spelunker to move, and what monitors keyboard input?

and what is the gamepad object?


Title: Re: Game Maker Help Thread!
Post by: halibabica on December 06, 2010, 04:59:48 PM
There's a script called CharacterStepEvent where it checks stuff related to controls.  They mostly refer to the whole pile of scripts in the folder called 'Control'.  This is where it checks for any and all buttons being pressed.

The gamepad object only comes into play if a gamepad is being used.  I really don't know much about it beyond that.


Title: Re: Game Maker Help Thread!
Post by: zetsu on December 06, 2010, 06:21:52 PM
is the script called by the oPlayer1 object or a different object?


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on December 06, 2010, 10:49:07 PM
any chance some one can help me fake a planet gravity program >?


Title: Re: Game Maker Help Thread!
Post by: halibabica on December 07, 2010, 05:27:17 AM
is the script called by the oPlayer1 object or a different object?
Yes, it is is called by oPlayer1 as part of its Step Event.

any chance some one can help me fake a planet gravity program >?
What exactly do you mean?


Title: Re: Game Maker Help Thread!
Post by: zetsu on December 07, 2010, 09:08:14 AM
Quote
Yes, it is is called by oPlayer1 as part of its Step Event

so if i wanted a second player i would have to create a second characterStepEvent with changed values to fit that player?

oh, and which object creates the spelunker every time for each new level?


Title: Re: Game Maker Help Thread!
Post by: halibabica on December 07, 2010, 10:36:58 AM
The nice thing about scripts is that they can be called by any object.  So to have a second player, you could still have the oPlayer2 object call the same script as oPlayer1.  But, due to the nature of this particular case, that would make both characters be controlled by the same keyboard/gamepad.  You'd probably have to make duplicate control scripts that check things separately for player 2 and add a lot of 'if' cases to the shared step event script (ex: if ((player1 and this) or (player2 and that)).

Also, oPlayer1 is created in a bunch of different places.  ScrLoadLevel for custom levels, oTitle for title screen navigation, but...I couldn't find the spot it creates it for actual levels in-game.  It's not in a script, though (I already searched those).


Title: Re: Game Maker Help Thread!
Post by: zetsu on December 07, 2010, 01:05:13 PM
Quote
The nice thing about scripts is that they can be called by any object.  So to have a second player, you could still have the oPlayer2 object call the same script .........levels, oTitle for title screen navigation, but...I couldn't find the spot it creates it for actual levels in-game.  It's not in a script, though (I already searched those).

thanks. I started a second copy of characterStepEvent and i'm changing all of the things to check for buttons with scripts i made that reference global variables i made for the second player.


Title: Re: Game Maker Help Thread!
Post by: zetsu on December 07, 2010, 03:08:50 PM
what makes oPlayer1 jump?
i changed all of the stuff in characterStepEvent,which is actually only called once in the oPlayer1, and now my oPlayer2 object can use the arrow keys to move and can run but can't jump.


Title: Re: Game Maker Help Thread!
Post by: PhilipT97 on December 20, 2010, 09:07:05 PM
hello, I am new to modding spelunky and have no game maker experience.  I am trying to find a way to take a list of objects on a text file in the spelunky folder and have them spawn next to the spelunker whenever the game loads a level.  So far I added a new code snippet to the spelunker's create event.
Code:
Instance_create(x,y,oJetpack)
I find that it spawns correctly in the menu but during the level it spawns in the top left corner of the level.

I would appreciate help with my cheat mod if anyone is willing to help


Title: Re: Game Maker Help Thread!
Post by: halibabica on December 20, 2010, 09:30:54 PM
If you want the player to always start with a Jetpack, there's only one thing you need to change.  In the scripts folder, there's a script called 'scrClearGlobals'.  Inside that, find the line that says 'global.hasJetpack = false;'.  Change the 'false' to 'true' and the player will always have a Jetpack.  No need to spawn the item itself anywhere at all.


Title: Re: Game Maker Help Thread!
Post by: PhilipT97 on December 21, 2010, 09:39:31 AM
and lets say i want to change that to a shotgun... edit the source code again?
If i loose it on level two will it re-spawn on level three?


Title: Re: Game Maker Help Thread!
Post by: Kegluneq on December 21, 2010, 02:21:52 PM
Unfortunately, the shotgun is a held item, not a power-up item, so you can't do hali's trick.
However if you try the instance_create method again, but replace x,y with oEntrance.x, oEntrance.y it should spawn the shotgun (or whatever other item you may want) right at your feet at the beginning of each level.


Title: Re: Game Maker Help Thread!
Post by: PhilipT97 on December 21, 2010, 05:05:53 PM
THANK YOU  ;D
Now I'll just add an if statement to only spawn it if helditemtype doesn't equal "oShotgun"?

p.s. would it even be possible to read the object i want to spawn from a file in the spelunky directory?


Title: Re: Game Maker Help Thread!
Post by: halibabica on December 21, 2010, 05:22:13 PM
I think it's possible, but it's completely unnecessary.  Any object you need the game to create, you can call with instance_create.  If it's a custom object, you can just add it into the code.


Title: Re: Game Maker Help Thread!
Post by: Kegluneq on December 21, 2010, 07:08:17 PM
Yes it is possible, but I don't know how off the top of my head.
Search the help for i/o. You may find what you want there.


Title: Re: Game Maker Help Thread!
Post by: hyperme on December 30, 2010, 01:54:15 PM
IGNORE ME!

I fixed it myself.


Title: Re: Game Maker Help Thread!
Post by: Arucard on January 02, 2011, 04:36:58 PM
Just another option, but there's a debug portion in the player object which you can add this to as well. A simple button press (backspace I think) could spawn the object near you.


Title: Re: Game Maker Help Thread!
Post by: Lilyo on January 09, 2011, 01:31:48 PM
I tried looking through the first post but I couldn't find much, so can someone just kinda teach me the basics of moding a game? All i really wanna do is edit the textures, but I've never done anything like this before, and I'd rather just someone explain it to me :C
What program do I need, where are the textures located, is it just a straightforward retileing sort of thing, or is it more complicated, etc


Title: Re: Game Maker Help Thread!
Post by: halibabica on January 09, 2011, 02:50:17 PM
To get started, you'll need Game Maker.  The full version is $25, but you can download a free one that's more limited.  You don't need the full version to edit graphics.  Once you have the program (and Spelunky's source), you can change its looks to your heart's content.


Title: Re: Game Maker Help Thread!
Post by: banna8 on March 01, 2011, 03:14:19 PM
Hi, I was wondering if it was possible to make an object move along a moving path. Like if I where to make a characters feet move along a walking path, while stile staying underneath the body of the character (another object). Or do I have to just make an animated sprite for the foot and have it be pinned underneath the character. however this second option would be very tedious, as I plan on allowing the player to change shoes and stuff, and if the feet could follow a path, i could just change the sprite using a global variable.


Title: Re: Game Maker Help Thread!
Post by: halibabica on March 01, 2011, 03:37:05 PM
I assume this is for that Rayman thing you were working on.

I'd set the feet to stay a certain distance from the body and move to follow it when that distance grows.  So the feet would try to stay at oBody.x+8 or something, and if it wasn't in that exact position, it'd increase it's xVel or yVel until it was.

That's the basic idea of it, but I can imagine it taking a lot of refinement not to look absolutely wacky.


Title: Re: Game Maker Help Thread!
Post by: Zambaku on March 03, 2011, 08:24:44 AM
I'm having a bit of trouble with one of my new enemies. It's 32x32 and sometimes when it spawns it dies right away due to lack of space. How do I go about making it spawn in a place with enough space?

Also, I can't get it's movement right. It just keeps walking of ledges, instead of turning. And when it bumps into a wall it just continues to try and walk through it instead of turning =/

The monsters step code:
Code:
if ((x > view_xview[0]-36 and x < view_xview[0] + view_wview[0] and
        y > view_yview[0]-36 and y < view_yview[0] + view_hview[0]))
{
moveTo(xVel,yVel);

yVel += myGrav;
if (yVel > yVelLimit) yVel = yVelLimit;

if (collision_point(x+16, y+16, oSolid, 0, 0))
{
    hp = 0;
}

if (hp < 1)
{
    scrCreateBlood(x+14+rand(0,4), y+14+rand(0,4), 4);
    repeat(4)
    {
        instance_create(x+14+rand(0,4), y+12+rand(0,6), oBone);
    }
    if (global.currLevel == 13) instance_create(x+16, y+16, oPotion);
    if (countsAsKill)
    {
        if (isRealLevel()) global.enemyKills[20] += 1;
        global.tomblords += 1;
        global.kills += 1;
    }
    instance_destroy();
}

if (isCollisionBottom(1) and status != STUNNED)
    yVel = 0;

if (attackTimer > 0) attackTimer -= 1;
if (whipped > 0) whipped -= 1;
   
if (status == IDLE)
{
    if (counter > 0) counter -= 1;   
    if (counter <= 0)
    {
        status = WALK;
    }
}
else if (status == WALK)
{
    if (counter > 0) counter -= 1;
   
    if (facing == LEFT)
    {
        if (isCollisionLeft(1) or
            (oPlayer1.x > x+16 and abs(oPlayer1.y-(y+32)) < 16 and counter == 0))
        {
            sprite_index = sDragonWalkR;
            status = TURN;
            counter = 30;
        }
        else if (oPlayer1.x < x+16 and abs(oPlayer1.y-(y+16)) < 32 and attackTimer == 0)
        {
            status = ATTACK;
            sprite_index = sDragonFire;
            image_index = 0;
            xVel = 0;
        }
        else xVel = -1;
    }
    else if (facing == RIGHT)
    {
        if (isCollisionRight(1) or
            (oPlayer1.x < x+16 and abs(oPlayer1.y-(y+32)) < 16 and counter == 0))
        {
            sprite_index = sDragonWalkR;
            status = TURN;
            counter = 30;
        }
        else if (oPlayer1.x > x+16 and abs(oPlayer1.y-(y+16)) < 32 and attackTimer == 0)
        {
            status = ATTACK;
            sprite_index = sDragonFireR;
            image_index = 0;
            xVel = 0;
        }
        else xVel = 1;
    }
}
else if (status == TURN)
{
    xVel = 0;
}
else if (status == ATTACK)
{
    xVel = 0;
    image_speed = 0.5;
    attackTimer = 100;
    if (image_index >= 7 and image_index <= 12)
    {
        if (facing == LEFT)
        {
            obj = instance_create(x+8, y+12+rand(0,4), oFireBall);
            obj.xVel = -rand(3,5);
        }
        else
        {
            obj = instance_create(x+24, y+12+rand(0,4), oFireBall);
            obj.xVel = rand(3,5);
        }
    }
}
else if (status >= STUNNED) status = WALK;

if (isCollisionSolid())
    y -= 2;

if (facing == LEFT)
{   
    if (status == WALK) sprite_index = sDragonWalk;
    else if (status == IDLE) sprite_index = sDragonLeft;
}
if (facing == RIGHT)
{   
    if (status == WALK) sprite_index = sDragonWalkR;
    else if (status == IDLE) sprite_index = sDragonRight;
}
}


Title: Re: Game Maker Help Thread!
Post by: halibabica on March 03, 2011, 10:20:27 AM
Try examining how other similar enemies behave.  For example, Hawkmen don't walk off of edges, so you could look in its step event to find the way to prevent that.  Likewise, cavemen will turn around when they bump into a wall, so find the code in their step event that makes them do so.  You could also look at the entity generating script to find the restrictions the game sets on making Tomb Lord appear so it only shows up where it's safe.


Title: Re: Game Maker Help Thread!
Post by: Sparkle on July 07, 2011, 12:30:38 PM
I HAVE A QUESTION:
Without having Game Maker Pro, would I be too limited to have it connect to the internet?


Title: Re: Game Maker Help Thread!
Post by: Kegluneq on July 08, 2011, 01:41:36 PM
I don't get the question.
If you mean "Can I only use the lite version when connected to the internet?" then no. There are no restrictions as to when and where you can use it, only what you can make.

If you mean "Can I use certain game making features that use the internet (like multiplayer games)?"  then yes, lite can do that too!


Title: Re: Game Maker Help Thread!
Post by: Sparkle on July 08, 2011, 05:01:11 PM
YAY! :D thanks, it was the second question. and sorry, I wasn't sure how to word that properly xD


Title: Re: Game Maker Help Thread!
Post by: DrWhoFan82 on July 15, 2011, 09:57:55 PM
Where can I find the software to modify this game?


Title: Re: Game Maker Help Thread!
Post by: Sparkle on July 15, 2011, 10:02:09 PM
you can go to yoyo games' website, and download "Gamer Maker" :)

http://yoyogames.com/gamemaker/windows Download the "Lite" version if you want the free one :3


Title: Re: Game Maker Help Thread!
Post by: Straucher on July 18, 2011, 01:40:51 PM
How would I add my own custom objects and categories to the level editor?


Title: Re: Game Maker Help Thread!
Post by: halibabica on July 22, 2011, 05:34:29 AM
It's complicated.

1. Add the new object category variables to the list in oLevelEditor's create event.  You'll see a bunch already there called blockArray, trapArray, etc.  You'll need one of those and a number for each object in the array.  You'll also need a symbol for each object you add.  Spelunky already uses most of the letters and numbers, so you'll need to dive into some special ASCII characters to avoid dropping other objects.  Finally, you'll need another variable added under the array lists to go with the BLOCKS, ENEMIES, TRAPS, and ITEMS variables.

2. Add a press-number event to oLevelEditor for your new array.  You can copy one of the existing ones and just change the variables inside to match those of the array you're adding.

3. In oLevelEditor's step event, copy+paste another of the drop select script blocks and change the variables needed.

4. In the Level Editor scripts, add your objects and the symbols they use to scrCreateTile, scrCreateTileObj, and scrSetCursorTile.

If you do all that correctly, you'll have a new drop array that can place objects in the level.

If that sounds too hard, you can always just use the Editor Plus mod which already has almost everything you could ask for anyway.


Title: Re: Game Maker Help Thread!
Post by: Straucher on July 25, 2011, 11:22:23 AM
I'll take a shot at it.


Title: Re: Game Maker Help Thread!
Post by: Bae on November 22, 2011, 02:56:46 AM
So hi guys

Mars and I are making a game in GM and are using the same engine that Derek adopted for spelunky, only we're having trouble getting the player character to work right

Mars says its something to do with the mask but I don't really understand GM terms so I'm just going to explain it in my own words and probably get corrected later

Here is a screen cap of the problem: http://i43.tinypic.com/nfmfkl.jpg

Basically the collision box is really really tiny, the one being used was meant to go with a 16x16 mario sprite that was present in the engine so our sprite is sunken into the floor and hangs off of stuff by his shoulders. The main problem here is that we can't figure out how to change the collision box, Mars said he couldn't find any mention of the mask or whatever anywhere in the code, so if anyone could help figure that out it would be greatly appreciated.


Also Mars is having issues with player attacks but I still dont understand the problem so I'll have to ask about that later.


Title: Re: Game Maker Help Thread!
Post by: Wonkyth on November 22, 2011, 06:24:48 AM
If Mars wants to upload any relevant pieces of code, in text form, I'd be more than happy to apply my mammoth brain to the problem. =P


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on November 22, 2011, 11:58:33 AM
If Mars wants to upload any relevant pieces of code, in text form, I'd be more than happy to apply my mammoth brain to the problem. =P
How about I just throw you the code?
http://www.mediafire.com/?mnu5d3kpv1udkin
(most of value we have is a plan so theres no harm shareing this, it doesn't even have the real sprites yet


Title: Re: Game Maker Help Thread!
Post by: halibabica on November 22, 2011, 08:22:43 PM
Um, not sure how much any of this helps, but...as far as I know, collision detection in GM can work in two ways.

1. sprite collision boxes
  These are set on a per-sprite basis in GM's sprite editor.  It can be set to be a rectangle, circle, diamond, or match the pixels of the sprite exactly.  Any place where a sprites collision box touches that of another sprite, a collision is detected.

2. coding
  Any code with 'collision' in its name is checking for a collision (like collision_point, collision_rectangle, etc.).  Used as an if case, these will cause the code following them to happen if a collision is detected as specified.

That's all I know about collision in GM.  You might also want to look at the collision scripts in Spelunky, though...


Title: Re: Game Maker Help Thread!
Post by: Moloch on November 22, 2011, 08:34:28 PM
The platform engine you're using has its own set of collision scripts instead of using GM's built-in stuff. In the characterCreateEvent script, line 68, I changed it to:

Code:
setCollisionBounds(-4,-32,16,68)

which is still off a bit.. :-[ 

The way that's set up would seem to force you to use the same dimension sprite (or just collision mask?) for all the player sprites? (I am mentally impaired at the moment).


Title: Re: Game Maker Help Thread!
Post by: Bae on November 22, 2011, 10:37:11 PM
That's actually a lot off but it works better than what we had

What do the numbers refer to .u .


also I remembered another problem we were having, we cant find the variable to change walk speed or the acceleration of the run button (if you hold ctrl in the game that blue bar at the bottom fills up and you start to run when its full enough, only that's totally disorientating and we'd rather have a more instantaneous affect)


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on November 22, 2011, 10:39:31 PM
The platform engine you're using has its own set of collision scripts instead of using GM's built-in stuff. In the characterCreateEvent script, line 68, I changed it to:

Code:
setCollisionBounds(-4,-32,16,68)

which is still off a bit.. :-[ 

The way that's set up would seem to force you to use the same dimension sprite (or just collision mask?) for all the player sprites? (I am mentally impaired at the moment).

Oh THATS where it is. Thanks, I can figure it out from there.

Now I just need to figure out how to steal spelunky's attack code and make it work, and what bae said


Title: Re: Game Maker Help Thread!
Post by: halibabica on November 23, 2011, 04:48:22 AM
Those numbers refer to the left, top, right, and bottom collision points for the sprite.  They are based off where the sprite is drawn from, which is something you set on the sprite itself.  In Spelunky, the player is drawn from the center of his sprite (8, 8).  Enemies and most other things are drawn from their top left corner (0, 0).

So setting the collision bounds as (-4, -32, 16, 68) tells the game 'this sprite collides four pixels to the left of its draw point, 32 pixels above it, 16 beyond it, and 68 below it.  The correct collision bounds depend entirely on where the sprite is drawn from.

Also, even though Spelunky DOES use its own method of determining these things, the built-in GM stuff still plays its role also, and you should set those factors as well just to be safe.

Also, running in Spelunky is handled in the step event script for oPlayer1 (the one that's called, not the one in the object itself).  The attack events are in the oPlayer1 step event in the actual oPlayer1 object (somewhere).


Title: Re: Game Maker Help Thread!
Post by: Wonkyth on November 23, 2011, 05:37:12 AM
Lol smilycode fail. =D


Title: Re: Game Maker Help Thread!
Post by: halibabica on November 23, 2011, 10:58:20 AM
Watchoo talkin' 'bout?  I set sprites to be drawn from (8, 8)) all the time.


Title: Re: Game Maker Help Thread!
Post by: Wonkyth on November 23, 2011, 11:44:14 PM
I love graphics complex numbers, but how does one graph a complex number with  8) instead of i?


Title: Re: Game Maker Help Thread!
Post by: halibabica on November 24, 2011, 06:36:15 AM
You must imagine the 10th dimension first (http://www.youtube.com/watch?v=8Q_GQqUg6Ts).


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on November 24, 2011, 12:19:08 PM
You must imagine the 10th dimension first (http://www.youtube.com/watch?v=8Q_GQqUg6Ts).
Ok then so where does 8) come into it?


Title: Re: Game Maker Help Thread!
Post by: halibabica on November 24, 2011, 07:33:14 PM
That is the ultimate question.

The answer is 42.

We can talk about GM problems again now.


Title: Re: Game Maker Help Thread!
Post by: Bae on November 24, 2011, 10:23:47 PM
You must imagine the 10th dimension first (http://www.youtube.com/watch?v=8Q_GQqUg6Ts).

That video literally put my to sleep
Ive been up all night and after watching that I was like fuck it and rolled over

Now I woke up at 9pm look at what youve done


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on November 24, 2011, 11:02:17 PM
That is the ultimate question.

The answer is 42.

We can talk about GM problems again now.

Ok, can you point me to where I should look to steal study the spelunky code to make weapons work?


Title: Re: Game Maker Help Thread!
Post by: Kegluneq on November 25, 2011, 12:41:04 AM
oPlayer1 Step Event, one of the action scripts is all about item usage.


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on November 25, 2011, 01:58:17 AM
oPlayer1 Step Event, one of the action scripts is all about item usage.
I'm not quite sure how to apply it to a "clean" state engine that he used.. I'm trying though


Title: Re: Game Maker Help Thread!
Post by: halibabica on November 25, 2011, 04:37:09 AM
That code checks for whatever item the player is holding to determine what happens when you press the action key.  Unless your game uses the same item mechanics as Spelunky (holding/not holding), copying it isn't going to help.  And even if yours does, it will only help a little.


Title: Re: Game Maker Help Thread!
Post by: Wonkyth on December 18, 2011, 06:15:20 AM
Okay, gonna buy GM. Any pointers?


Title: Re: Game Maker Help Thread!
Post by: Bae on January 31, 2012, 09:01:12 PM
Okay so let's say someone wants to add to the total of songs that can be used in the level editor

and make a new border type for editor levels

and put objects into a new array

how would one go about doing those?


Title: Re: Game Maker Help Thread!
Post by: halibabica on January 31, 2012, 10:32:31 PM
Adding new songs requires messing around with the file 'supersound.dll' which I know absolutely nothing about.  New tracks are impossible to add without changing it somehow.

Those other two things are a lot more complicated, and I don't have time to give a full response right now.  So...maybe later.  Sorry for being useless!


Title: Re: Game Maker Help Thread!
Post by: Skoke on March 29, 2012, 04:12:31 PM
When I try to run spelunky from gamemaker (the green arrow) it says error in omusic anyone know what the problem is? I've been using the spelunky forums mod to base my cavestory skin on because it's the only gmk that works

Also I know you can make a 3-d game in gamemaker does anyone know what format the 3d models need to be in? I don't plan on making a game but I am doing 3d modeling and was wondering what program I'd need for gamemaker


Title: Re: Game Maker Help Thread!
Post by: halibabica on March 29, 2012, 06:14:13 PM
Can you be more specific about the error you receive?  It should give you a number for the line where the error occurs.


Title: Re: Game Maker Help Thread!
Post by: Moloch on March 29, 2012, 07:02:55 PM
When I try to run spelunky from gamemaker (the green arrow) it says error in omusic anyone know what the problem is?

It's bitching because it can't find the rest of the files Spelunky is dependent on (specifically supersound.dll). Copy *.dll, *.cfg, and the 'sound' folder from your Spelunky installation to where you are saving your source so you can run test compiles from there.


Title: Re: Game Maker Help Thread!
Post by: halibabica on May 27, 2012, 07:44:09 AM
I'm thinking about getting back into modding soon (gonna pick up Spelunkémon again, yay!), but I wanted to ask if there were any compatibility issues with GM 8.1 and Spelunky first.  I have GM 8 on my old compy, but I'd like to get it on my newer computer, and I don't want to buy the upgrade only to find out it was a mistake.  Are there any troubles I'd run into?


Title: Re: Game Maker Help Thread!
Post by: hyperme on May 27, 2012, 11:19:10 AM
buy the upgrade

Wait are you telling me you have to pay to go from 8.0 to 8.1? Because that ain't right. morally or something.


Title: Re: Game Maker Help Thread!
Post by: halibabica on May 27, 2012, 04:11:11 PM
Well, I dunno about that, but I can't get the same GM license on two different computers is the thing.  Since I have to buy it again for my new computer anyway, I wanted to make sure before I got 8.1 if it would cause me problems.


Title: Re: Game Maker Help Thread!
Post by: TyrOvC on May 27, 2012, 09:19:28 PM
There's no compatibility issues with compiling Spelunky with GM 8.1. It even has lower cpu usage and fixes some gpu blackscreen bugs.

The Spelunky 1.2 project's language translation branch use 8.1 for better unicode support.


Title: Re: Game Maker Help Thread!
Post by: Moloch on May 28, 2012, 10:00:59 AM
I paid for 8.0, and got the 8.1 upgrade for free. I have both versions installed on the same machine if I need 8.0 for any reason. (EDIT: didn't see you are trying to use a different comp...that sucks)

The only issue with Spelunky was modding Editor Plus - loading the source into 8.1 replaced ALL the extended ascii characters in teh code used for the tiles with that square symbol. I'm guessing this has something to do with the new unicode support? I didn't put any effort into finding a solution and switched to 8.0 for that...so TLS will be effected too.


Title: Re: Game Maker Help Thread!
Post by: halibabica on May 28, 2012, 02:01:26 PM
Oh, so that's what the issue was.  I wonder if there's a way around that...

Anyway, if that's the only difference, then I'm less concerned about changing over.  It's actually kinda handy, 'cuz if I can't find a solution to the unicode problem, I'll still have 8.0 on my other machine.


Title: Re: Game Maker Help Thread!
Post by: Moloch on May 28, 2012, 02:15:33 PM
Just played around with it a bit...
You can export the effected scripts from 8.0 and import into 8.1 and it doesn't screw up the extended ascii. For GML in objects you can copy-paste into 8.1 fine. Bit of a pain, but after saving/loading it still looks ok.

EDIT - from release notes:
Quote
PLEASE NOTE: The Code Editor is now full unicode, however... this means that you WILL have to re-enter all your strings in order for them to work. This is because we have no idea what codepage they originally came from, so cannot patch up characters >127 into the correct unicode space. You can cut and paste them so that windows does this, but it's still going to be painful. Sorry....

-_-


Title: Re: Game Maker Help Thread!
Post by: Nathan on June 03, 2012, 10:00:32 PM
I don't know if this thread is just for Spelunky or all gamemaker games but I have a question. I just started adding some sound to a game i'm working on and the file size EXPLODED!!! Two sounds brought the file size from 28kb to 108kb. Is there a way to store sounds in a separate folder and load them in separately?


Title: Re: Game Maker Help Thread!
Post by: halibabica on June 04, 2012, 04:06:53 AM
Um, 80 kb isn't exactly an explosion.  But yeah, sounds can tend to take up a lot of file size, especially if they're .wav format.  You shouldn't worry about it unless the game has a hard time loading them for some reason.


Title: Re: Game Maker Help Thread!
Post by: Nathan on June 04, 2012, 01:18:17 PM
ok


Title: Splash Screen Headache...
Post by: idyll on July 05, 2012, 07:49:49 PM
I've searched for the answer to this question, but have had no luck. I'm hoping it's an easy fix. I'm converting the 1.2 version of Spelunky to Game Maker 7 (I'm using a Mac and GM7 is the only option besides Studio right now), but I'm having an issue with the splash image that first appears when you start the game.

You know the image where the "Main Dude" is sitting down looking at a map, holding his whip and surrounded by a bat and a snake? The background is supposed to be black, but for me it's white. I'm guessing the issue is one of transparency, but I can't find the image to edit it or change its settings.

I've been searching the source code for hours now. Please help.

???


Title: Re: Game Maker Help Thread!
Post by: Nathan on July 05, 2012, 08:23:42 PM
If it still looks okay keep it. Otherwise go to the global game settings (It's a button along the top of the form) find the load screen image option and check where its located. If you can't locate it click load image and implement a duplicate from google images.


Title: Re: Game Maker Help Thread!
Post by: idyll on July 05, 2012, 09:32:58 PM
Thank you for your quick reply, but I'm having trouble following your directions. When I go under "Global Game Settings" and click the "Loading" tab, I don't see the "load screen image option." However, I assume you mean the "Change Image" button. Is this what you meant? When I click the button it takes me to the same directory as the Spelunky 1.2 gmk file. There is no image file it appears to be pointing to. I'm guessing the loading screen image is within the gmk file.

Is there a way to edit the loading screen within Game Maker 7? Is there another program that can export the image so that I can edit it? I could do a screen cap of the Windows version and edit that, but I'd rather edit the original image. Any ideas?


Title: Re: Game Maker Help Thread!
Post by: Nathan on July 05, 2012, 09:41:15 PM
I did mean change image. I feared the image would be within the gmk. Change it to this: https://encrypted-tbn3.google.com/images?q=tbn:ANd9GcROjTdPn1ljgSoCqzXnIdOJGCrPSdA-nbGPsk-3wnortJwrkKrGXA

You may need to remove the background. This can be done with two clicks in paint.net using the magic wand. If you can't figure it out I will help. To change it when it brings you to its directory locate the image once its saved to your desktop


Title: Re: Game Maker Help Thread!
Post by: idyll on July 05, 2012, 10:10:47 PM
I did a screen capture of the image and with some editing in gimp did what you suggested. I added an alpha layer to the image, selected the background parts with the fuzzy select tool and pressed the delete key. Now I've got a png with a transparent background that seems to work fine as the loading image.

I still find it strange that the first image a player potentially sees can't be easily edited within Game Maker, but what do I know...  :D  Thanks for your help and quick replies.


Title: Re: Game Maker Help Thread!
Post by: Nathan on July 05, 2012, 10:12:39 PM
No problem! If you run into any more trouble I will try my best to help you out.



Title: Re: Game Maker Help Thread!
Post by: TyrOvC on July 09, 2012, 02:25:17 PM
@idyll
The Caster Extension http://moacube.com/resources/caster-multi-platform-ogg-extension-for-gamemaker/ is probably a good way to play Spelunky's music and sound files on Mac.


Title: Re: Game Maker Help Thread!
Post by: idyll on July 10, 2012, 05:06:44 AM
Thank you for the suggestion TyrOvC, but using Caster is what I planned to do all along.  ;D  I've accomplished about one third of what I want to do with the source code (that includes implementing Caster audio), but I'm now having issues with Game Maker 7 for Mac.

I'm using Game Maker Pro 7.5.87 and when I try to "Create Executable" it seems to work fine except when I try to run the resulting app. The Spelunky logo pops up and then I get a black screen and no sound. This happens with Spelunky 1.0, 1.1, 1.2 and my modified version of the 1.2 source. I can exit the game with the "Esc" and "F10" key combo or "F4" and selecting "Quit", so the game logic is still working to some degree...

Here's the weird part. All those same versions of the game run fine (except for the Supersound errors) when I use "Run the game" from within Game Maker. I want to implement more changes in the code, but without the ability to redistribute a working executable, I don't see much point.

If I can't find any help here then my next step will be to contact L about his Mac port of Spelunky 1.0: http://mossmouth.com/forums/index.php?topic=2157.0 (http://mossmouth.com/forums/index.php?topic=2157.0) Thought I'd give the forum a go before I PM him. Worst case scenario, I'll just share the modified source as is and walk away.

Please help if you can, because I don't want to give up before I've barely begun.  :-\


Title: Re: Game Maker Help Thread!
Post by: Nathan on July 10, 2012, 10:29:06 PM
DONT GIVE UP!!! Btw why do you want spelunky to run in game maker 7?


Title: Re: Game Maker Help Thread!
Post by: idyll on July 10, 2012, 11:23:43 PM
It's not that I want Spelunky to run in Game Maker 7; I have little choice. GameMaker 8 and 8.1 for Mac doesn't exist. I love Spelunky and want to play the latest and greatest version on my Mac. I can't afford GameMaker: Studio and the beta version wouldn't run Spelunky when I tried it. Frankly, Game Maker 7 for Mac is crap. It's glitchy, full of bugs and has crashed on me many times, but it's the only affordable choice for this Mac user.   :-\

I could wait for GameMaker 9, but who knows when that'll be released or how much it'll cost...


Title: Re: Game Maker Help Thread!
Post by: Nathan on July 10, 2012, 11:34:28 PM
I think someone has already ported it to mac

EDIT: They have http://mossmouth.com/forums/index.php?topic=2561.0


Title: Re: Game Maker Help Thread!
Post by: Wonkyth on July 10, 2012, 11:37:47 PM
Not sure how good wrapping is compared to compiling with a Mac version of Gm, though.


Title: Re: Game Maker Help Thread!
Post by: Nathan on July 10, 2012, 11:39:12 PM
If its bad than this is for 1.0 http://mossmouth.com/forums/index.php?topic=2157.0


Title: Re: Game Maker Help Thread!
Post by: idyll on July 11, 2012, 12:36:29 AM
Thanks for the heads up nathantcash, but I already linked to that native Mac port in a previous post. Wonkyth is right that a version compiled specifically for Mac would be a better option. I've sent a PM to the creator of the "Mac port of Spelunky 1.0," but he doesn't appear to be active on this forum. So, who knows when or if I'll hear anything back. Fingers crossed. :)


Title: Re: Game Maker Help Thread!
Post by: Nathan on July 11, 2012, 12:46:09 AM
He hasn't been active since january


Title: Re: Game Maker Help Thread!
Post by: winterdrake on July 12, 2012, 06:19:36 PM
WOW! This is amazingly helpful!
I need a really simple mod made. Anyone who can code/compile it will be my best friend for eternity.
As much as I love PC Spelunky, it cannot compare to the XBLA version in one aspect: Restarting. When you die, going to the highscore room, then to the spawn room, then to the shortcut room can take about 15 seconds, which is really just annoying.
Can someone code in a quick- restart button? So, that, when you die, it says "Press Z to restart. Press X for Highscores.". When you press Z, it would restart you from where you began (if you used a shortcut tunnel, it would start you off in that level). This would be amazingly helpful. Thank you so much!! ;D


Title: Re: Game Maker Help Thread!
Post by: Nathan on July 12, 2012, 09:17:57 PM
I WILL!!! I won't be able to do it until tomarrow though


Title: Re: Game Maker Help Thread!
Post by: L on July 13, 2012, 06:50:10 AM
Thank you for the suggestion TyrOvC, but using Caster is what I planned to do all along.  ;D  I've accomplished about one third of what I want to do with the source code (that includes implementing Caster audio), but I'm now having issues with Game Maker 7 for Mac.

I'm using Game Maker Pro 7.5.87 and when I try to "Create Executable" it seems to work fine except when I try to run the resulting app. The Spelunky logo pops up and then I get a black screen and no sound. This happens with Spelunky 1.0, 1.1, 1.2 and my modified version of the 1.2 source. I can exit the game with the "Esc" and "F10" key combo or "F4" and selecting "Quit", so the game logic is still working to some degree...

Here's the weird part. All those same versions of the game run fine (except for the Supersound errors) when I use "Run the game" from within Game Maker. I want to implement more changes in the code, but without the ability to redistribute a working executable, I don't see much point.

Well, here's one thing that might be of assistance:

The working directory for loading files is different for compiled executables than it is for in-editor running. For executables, it's "<filename>.app/Contents/MacOS/". (Even though it's probably a bug, it also makes sense as a behaviour that allows you to store and reference game resources inside the app bundle, as a Mac application best practice.) So if you want to open a file in a folder called "sound" in the same directory as the app, you have to use sound_add("../../../sound/file.mp3") and so forth. Consider adding a Constant called something like PATH, use it in all file i/o calls (for instance, sound_add(PATH + "sound/file.mp3")) and set it to "" when testing it in the editor and "../../../" or whatever when you build the executable.

I'm not sure what the problem with the graphics might be. Have you tried stripping out the draw_set_blend_mode_ext() related calls in oScreen? Those might have something to do with it.


Title: Re: Game Maker Help Thread!
Post by: winterdrake on July 13, 2012, 05:55:14 PM
I WILL!!! I won't be able to do it until tomarrow though

Thank you!


Title: Re: Game Maker Help Thread!
Post by: Nathan on July 13, 2012, 06:05:28 PM
Hey do you want the restart to always start you on level one or on the area you start on?

EDIT: I LOOKED AT YOUR POST AGAIN


Title: Problem Solved!
Post by: idyll on July 14, 2012, 02:14:55 PM
I fixed the problem! Thanks L for responding to my pleas for help. Your information about the working directory is what pointed me to the issue. The fix seems so obvious now and was a change I was going to make anyways. :)

When the Game Maker editor runs an executable it compiles the app, copies it to the /tmp directory and executes it with the argument "-YYDir /Path/to/the/gmk/file/" "-YYDir" is how it sets the working directory. Without that argument the app uses the working directory of the "YoYo70" executable located in "YourApp.app/Contents/MacOS/" (just like L mentioned). By default, that working directory contains "archive.dat", "gamedata.dat", "settings.cfg" and the "YoYo70" executable because Game Maker copies those files there when it creates an app.

So, "YoYo70" kept reading "settings.cfg" in the working directory (which Spelunky would consider giberish) and thus the default video settings weren't being implemented properly. If I had just kept going with my to do list and changed the reading and writing of the config files to the user's home directory, there would have been no problem.

In summation, I made a stupid mistake.  ;D

I've since fixed the problem by giving Spelunky it's own directory in ~/Library/Preferences/Spelunky. I also took L's advice about the sound files directory although I implemented it a little differently.

I'll be releasing the code and an app when I've run through the rest of my to do list. Thanks to L and everyone else who tried to help me. I've got a few more questions, but I'll put them in a post below this one.


Title: Re: Game Maker Help Thread!
Post by: winterdrake on July 14, 2012, 02:41:35 PM
Hey do you want the restart to always start you on level one or on the area you start on?

EDIT: I LOOKED AT YOUR POST AGAIN

Thanks! Are you gonna post it when it's done? Can you post a source file as well as the exe?


Title: Re: Game Maker Help Thread!
Post by: Nathan on July 14, 2012, 05:36:00 PM
Sure. My laptop went down recently and I couldn't work on it until today. It shouldn't be very hard to do. Once I'm done I am going to send you a copy and then send the code to ChazLouz so he can implement into into his ease of use mod.


Title: Re: Game Maker Help Thread!
Post by: winterdrake on July 15, 2012, 04:26:08 PM
Sure. My laptop went down recently and I couldn't work on it until today. It shouldn't be very hard to do. Once I'm done I am going to send you a copy and then send the code to ChazLouz so he can implement into into his ease of use mod.
Sounds good. When do you think you'll be finished?


Title: Re: Game Maker Help Thread!
Post by: Nathan on July 16, 2012, 01:11:24 AM
Sorry but I dont think I will be able to finish the mod. I couldn't find the needed info in the src


Title: Re: Game Maker Help Thread!
Post by: Nathan on July 16, 2012, 02:26:06 AM
Hey I need some help with a new object I am putting in my Spelunky mod. I already made it able to come out of chests and it can be picked up. What I want to do with it is when it is picked up it is destroyed (Like the Bomb bag) and a variable changes. How would I do this?


Title: Re: Game Maker Help Thread!
Post by: halibabica on July 16, 2012, 04:31:55 AM
You can do that through oPlayer1's coding. There's a section (two of them, actually) in the step event somewhere that change bomb and rope variables when Spelunker collides with those items. You can change the variable and destroy the item there, but you'll have to add it to both places.

Otherwise, you could set it in the item's step event that:

if (held)
{
change variable;
instance_destroy();
}

That should work, but test it to make sure.


Title: Re: Game Maker Help Thread!
Post by: Nathan on July 16, 2012, 11:43:38 AM
That's pretty simple I'll test it. Thanks


Title: Re: Game Maker Help Thread!
Post by: halibabica on July 16, 2012, 02:01:34 PM
Actually...thinking again, that could mess up one of oPlayer1's variables. If you want it to be picked up the moment the player bumps it, just use the code I described in a collision event instead (collision with oPlayer1, of course).


Title: Re: Game Maker Help Thread!
Post by: Nathan on July 16, 2012, 02:42:55 PM
I put it in the step event of the new item and nothing was messed up


Title: Help please
Post by: Darc_Wolf on August 02, 2012, 05:06:22 AM
So, I'm trying to add an item that basically doubles the length of your whip. So far, I have it mostly done. It only appears in shops, I've gotten it to appear.

I was sure this would happen, but it was the only way I could get it to work. Right now, in the items step event, I have


if (held)
{
hasLongWhip=true;
instance_destroy();
}

Of course, this means that if you pick it up from the shop, you get it, and you don't need to buy it since it just gives it to you. How do I make it so you have to buy it or drop it?


Title: Re: Game Maker Help Thread!
Post by: halibabica on August 02, 2012, 06:38:55 AM
For the shop question, I don't know exactly what you need to do, but take a look at how other items work in that regard. A straight copy/paste might even be safest.

I spotted something else you'll need to change in that code, though. You need to make 'hasLongWhip' a global variable. Otherwise, the player will lose it between rooms. Add 'global.hasLongWhip' to scrClearGlobals to establish it.


Title: Re: Game Maker Help Thread!
Post by: Darc_Wolf on August 02, 2012, 07:39:58 AM
Yeah, it was already a global variable, I just forgot to add that to my post. Also, what are the shop items? I copied and pasted from oMattock, which had a price and everything.


Title: Re: Game Maker Help Thread!
Post by: halibabica on August 02, 2012, 08:33:37 AM
Try copying something like the Climbing Gloves, or any other power-up that disappears when purchased. It should have the same properties as what you're adding.


Title: Re: Game Maker Help Thread!
Post by: Darc_Wolf on August 02, 2012, 08:55:46 AM
Er, I derped actually. I copied the Spike shoes (oSpikeShoes) not the Mattock. I suspect the code for making stuff disappear is in the a script for the player, not the item.


Title: Re: Game Maker Help Thread!
Post by: Moloch on August 02, 2012, 07:06:45 PM
Er, I derped actually. I copied the Spike shoes (oSpikeShoes) not the Mattock. I suspect the code for making stuff disappear is in the a script for the player, not the item.

If you haven't already, look at the scripts in the "Character" folder, especially scrStealItem (which handles buying items too) and scrHoldItem.


Title: Re: Game Maker Help Thread!
Post by: Darc_Wolf on August 02, 2012, 07:12:18 PM
Aha! Thank you very much! scrStealItem is exactly what I was looking for. Thanks.

EDIT:
What does "    global.equipped[8,1] = true
    global.equipped[8,2] = true
    global.equipped[8,4] += 1;"

mean? It's different for each item, and I have no idea how to use those. If it helps, I'm using the fanmod for YASM 1.6. (I don't plan on releasing this)


Title: Re: Game Maker Help Thread!
Post by: Nathan on August 02, 2012, 08:14:06 PM
YOU BETTER RELEASE IT PUNK!!!  ;D


Title: Re: Game Maker Help Thread!
Post by: Moloch on August 02, 2012, 08:21:43 PM
Aha! Thank you very much! scrStealItem is exactly what I was looking for. Thanks.

EDIT:
What does "    global.equipped[8,1] = true
    global.equipped[8,2] = true
    global.equipped[8,4] += 1;"

mean? It's different for each item, and I have no idea how to use those. If it helps, I'm using the fanmod for YASM 1.6. (I don't plan on releasing this)

That's the array for the worn item inventory (cape, shoes, etc) in YASM. It's initialized in scrClearEquipped.

item 8 = Jordans
8,1 = does  the player own them?
8,2 = if they are currently being worn?
8,4 = quantity owned (added by fan mod, so you can sell extra gear you pick up)

In hindsight, the inventory system was designed very poorly. It's functional, but not modular. I've wanted to add new items to the mod but my lack of forethought and sloppy coding have made it unappealing. In this case, the length of the inventory arrays are hard coded, when I should have set their length in a global variable when they were initialized or used Game Maker's built-in data structures. Apologies.

EDIT:
How about a mindfuck? Check the YASM 1.6 fanmod scrScumGlobals script, line 15. Change the value to 1. It works, but there is no item pickup for it.


Title: Re: Game Maker Help Thread!
Post by: Darc_Wolf on August 02, 2012, 09:40:37 PM
Yeah, it was weird working with that. I had trouble getting my whip upgrade to work until I added something small to the whip code. My guess is that's what he had trouble with, or he couldn't figure out how to add an item, oh well, I got mine to work.

Also, that seems to add it to the inventory, which is good, however, it'll take a bit more to be able to disable having a longer whip.


Title: Re: Game Maker Help Thread!
Post by: Moloch on August 02, 2012, 10:04:56 PM
The whip upgrade was something I never finished fleshing out some versions ago, so it was disabled.

Duh. I just realized that by replacing the Jordans with the long whip you avoid the mess of trying to add additional items to the inventory. Carry on..


Title: Re: Game Maker Help Thread!
Post by: Darc_Wolf on August 02, 2012, 10:19:19 PM
Um...actually, I managed to add it just fine. I just copied the one from paste, and changed the 13 to 14. Seems to work just fine.


Title: Re: Game Maker Help Thread!
Post by: Nathan on August 02, 2012, 11:11:56 PM
Hey can you seriously release this mod? Possibly as a new update to the original???


Title: Re: Game Maker Help Thread!
Post by: Darc_Wolf on August 02, 2012, 11:52:41 PM
Me? It's barely even a mod, and it's not even a mod of YASM, it's a mod of a fanmod FOR YASM. I mean, sure, now I added a thing that triples the whip's power (It does 3 damage if you have the item, instead of 1 damage)

Still doesn't warrant a new mod since it's pretty simple.


Title: Re: Game Maker Help Thread!
Post by: Nathan on August 03, 2012, 01:51:41 AM
Ya. Could you message me the code and instructions on how you implemented it? Or better yet release the mod :)


Title: Re: Game Maker Help Thread!
Post by: halibabica on August 03, 2012, 04:10:40 AM
People have released mods with smaller changes than that. You may as well.


Title: Re: Game Maker Help Thread!
Post by: Nathan on August 03, 2012, 11:58:50 AM
Like the Spelunky that always stays on top ;D


Title: Re: Game Maker Help Thread!
Post by: Darc_Wolf on August 03, 2012, 12:53:36 PM
Hm. Alright. Should I release it under the YASM thread or it's own thread?

Also, I was trying to do something funny. I tried making it so you could put Damsels in your inventory, but sadly, it didn't work. I was trying to make it so you could put EVERYTHING in your inventory, but like Moloch said, it seems like it's hard coded. Oh well. I'll do a few things and put the mod out.


Title: Re: Game Maker Help Thread!
Post by: Nathan on August 04, 2012, 01:50:34 AM
How do you create a separate collision for a part of a sprite. When I set a character to a punch animation there is nothing to see if his arm and only his arm hits an enemy and damages it. This is not related to Spelunky but I hope its okay to post


Title: Re: Game Maker Help Thread!
Post by: halibabica on August 04, 2012, 04:25:12 AM
That's kinda tricky. You could make a little attack animation sprite that does the damage on collision instead, but that might extend the punch's range too much. Otherwise, I think you'd have to make exceptions to the damage code like 'if not (punching)', etc. Or you could adjust the sprite's hit box to exclude the fist, depending on how far in front of the body it reaches.


Title: Re: Game Maker Help Thread!
Post by: Darc_Wolf on August 04, 2012, 04:41:36 AM
What you could also do is change the wind-up sprite of the whip to be nothing, then the 'outward' part of the whip to a little like sprite. When enemies hit the little punch it'll hurt them, but it should still be good.

Also, can someone answer my question about where I should post that little minimod?


Title: Re: Game Maker Help Thread!
Post by: halibabica on August 04, 2012, 04:45:47 AM
What you could also do is change the wind-up sprite of the whip to be nothing, then the 'outward' part of the whip to a little like sprite.
This is not related to Spelunky

They're asking for a different project of theirs, not a mod.


can someone answer my question about where I should post that little minimod?
Just make your own thread. We've had mods of mods before, and it's easier to keep track of them independently.


Title: Re: Game Maker Help Thread!
Post by: Darc_Wolf on August 04, 2012, 04:51:19 AM
Oops, sorry, didn't see that last part, my mistake. Alright, I'll release the mod then.


Title: Re: Game Maker Help Thread!
Post by: Wonkyth on August 04, 2012, 06:48:01 AM
Traditionally, you'd have the hit-box separate from the sprite, thus avoiding issues. :P


Title: Re: Game Maker Help Thread!
Post by: Nathan on August 04, 2012, 01:48:41 PM
So only make the fist collidable? Or a seperate object? Right now if an enemy runs into the back Of me while punching it gets hurt


Title: Re: Game Maker Help Thread!
Post by: Wonkyth on August 04, 2012, 11:15:51 PM
Yes, only the fist collidable.


Title: Re: Game Maker Help Thread!
Post by: Nathan on August 04, 2012, 11:31:51 PM
Would I be able to set each frame of a sprite to different masks or would I need a new sprite?


Title: Re: Game Maker Help Thread!
Post by: Wonkyth on August 05, 2012, 12:16:40 AM
Why bother with masks at all?
All you need is a rectangle or two.


Title: Re: Game Maker Help Thread!
Post by: Nathan on August 05, 2012, 12:42:03 AM
So manually apply rectangle colliders to each frame of the punch animation through gml? Sorry I am a bit confused


Title: Re: Game Maker Help Thread!
Post by: TyrOvC on August 05, 2012, 12:55:14 AM
There's several ways to do it. The most flexible way in Game Maker would be to create a separate sprite to use for a collision mask, setting it's collision settings to rectangle/seperate masks for each frame and drawing the collision mask you want.

 It would be simpler to be able to manually set masks for each individual frame in your sprite, but as far as I know GameMaker's manual collision mask setting for sprites can't be set for individual frames inside the sprite settings.


Title: Re: Game Maker Help Thread!
Post by: Nathan on August 05, 2012, 11:40:28 PM
It is possible to only make his hand collideable in the punch frame/animation. I fear that that would make him invincible while he is punching. So you are saying to draw a sprite with collision zones that would apply punch damage while enemies are still able to collide with the rest of his body?


Title: Re: Game Maker Help Thread!
Post by: Moloch on August 06, 2012, 07:41:42 AM
I know your question isn't about Spelunky, but that's where your answer lies. Look at the Action code in the player Step event.

When you attack with whip/machete/mattock, it creates oWhip/oSlash/oMattockHit. You could create something like oPunch over his hand (whether it's a 4x4 non-visible sprite or a flaming fist effect) that will handle the collisions.

image_index is the frame of the current sprite.


Title: Re: Game Maker Help Thread!
Post by: Nathan on August 06, 2012, 12:03:29 PM
How do you track sprite collisions though? I though you could only track object collisions? Oh nvm you mean to create an object over his hand. Okay that makes sense.


Title: Re: Game Maker Help Thread!
Post by: Moloch on August 06, 2012, 12:39:04 PM
Yeah, you assign the sprite to the object, so it uses the sprite mask for collisions.


Title: Re: Game Maker Help Thread!
Post by: TyrOvC on August 06, 2012, 02:15:10 PM
If you're using your own collision checking in your step event code instead of the collide event, you could also change the mask_index of the player to what you want, check collisions, then change it back.

example:
Code:
//Check to see if hitting enemy
if(sprite_index==sprite_player_punch){
    mask_index=cmask_player_punch;
}
if(mask_index!=-1){
  with(oEnemy){
    if(collision_rectangle(bbox_left,bbox_top,bbox_right,bbox_bottom,oPlayer,0,1){
       hp-=other.attackpower;
    }
    //Set mask back to equaling sprite
    mask_index=-1;
  }
}

If you're doing it like Moloch suggested, just give the object a sprite, and uncheck "Visible"


Title: Re: Game Maker Help Thread!
Post by: Nathan on August 06, 2012, 02:27:12 PM
I think ill go with moloch


Title: Re: Game Maker Help Thread!
Post by: Nathan on August 06, 2012, 10:35:28 PM
I changed the plife variable in the animation end and the clear globals scripts in spelunky and the character still starts out with 4 health!!! I changed the bombs and ropes in the same places and it worked! What am I doing wrong


Title: Re: Game Maker Help Thread!
Post by: halibabica on August 09, 2012, 09:25:25 AM
Plife is set in a bunch of different places. You must've missed one of the places where it is. I know there's a section of oPlayer1's code that sets it when you pass through door objects. Try looking there.


Title: Re: Game Maker Help Thread!
Post by: Nathan on August 09, 2012, 12:24:44 PM
okay ill look into it. I got it to work thanks


Title: Re: Game Maker Help Thread!
Post by: Nathan on August 20, 2012, 11:36:36 PM
Where are damsels generated?


Title: Re: Game Maker Help Thread!
Post by: Gorm on August 21, 2012, 04:08:22 PM
Where are damsels generated?
In scrTreasureGen, lines 73-79, basically. Unless you want the damsels in kisssing parlors or area 4 idol traps. Those are found somewhere in the scrRoomGen* scripts. All these scripts are found in "Scripts/Level Generation".

If you're using Game Maker 8.x, you can easily search in scripts (ctrl+alt+f). Makes finding things a lot easier.


Title: Re: Game Maker Help Thread!
Post by: Nathan on August 21, 2012, 10:42:16 PM
Thanks! I thought I looked through that script but I didn't!!! Also any idea to where the chance of snakes coming out of pots and bombs coming out of chests are? One more thing where is the bonus cash for beating the game calculated? Sorry for all the questions I'm just having a hard time locating scripts


Title: Re: Game Maker Help Thread!
Post by: Gorm on August 22, 2012, 06:01:11 AM
The code for booby-trapped chests is found in object oPlayer1, event Step, action 3. Should be around line 170, unless you modified that action of course. In that case just look for a comment "// open chest".
Things coming out of pots are found in the Destroy event of oJar (in Objects/Items).


Title: Re: Game Maker Help Thread!
Post by: Nathan on August 22, 2012, 06:24:06 AM
Thanks so much Gorm! I REALLY APPRECIATE IT!!!


Title: Re: Game Maker Help Thread!
Post by: IFapToYourSister on November 05, 2012, 05:18:29 PM
So I'm making a new game from scratch, and this happens:
Step event is this:
if (facingleft==true)
{
sprite_index=sprPlayerLeft
}
if (facingright==true)
{
sprite_index=sprPlayerRight
}

Hold Left event is this:
facingleft=true

Hold Right Event is this:
facingright=true

but for some reason: I recieve this error:
___________________________________________
ERROR in
action number 1
of  Step Event
for object oPlayer:

Error in code at line 1:
   if facingleft==true
     ^
at position 4: Unknown variable facingleft


Title: Re: Game Maker Help Thread!
Post by: Nathan on November 05, 2012, 08:11:31 PM
you failed to define the variable. In the creation code or at the beginning of the script type : facingleft=false; facingright=false;





Title: Re: Game Maker Help Thread!
Post by: IFapToYourSister on November 09, 2012, 01:55:41 PM

___________________________________________
ERROR in
action number 1
of Collision Event with object obj_spike
for object obj_player:

Error in code at line 1:
   if vulnerable=1; {
                 ^
at position 16: Statement expected.

Help!


Title: Re: Game Maker Help Thread!
Post by: hyperme on November 09, 2012, 03:56:21 PM
you gotta put your if conditions in brackets. eg:

Code:
if(salad = tasty)
{
the hell are you even doing salad is terrible?
}


Title: Re: Game Maker Help Thread!
Post by: Moloch on November 09, 2012, 08:21:47 PM
Code:
if(salad = tasty)
{
the hell are you even doing salad is terrible?
}

LOL! Good example!


Error in code at line 1:
   if vulnerable=1; {
                 ^
at position 16: Statement expected.

Help!

Just get rid of the semicolon. The () brackets are optional, but can make things easier to read if you have a longer complicated 'if' statement, or just prefer the way it looks.


Title: Re: Game Maker Help Thread!
Post by: Urza on November 09, 2012, 09:20:50 PM
I'm not sure how much of this is strictly required, but normally people write ifs with the condition in parenthesis, a double == and like Moloch said, definitely no semicolon.

IMHO the "ideal" form looks like this:
Code:
if (MyVar == 10) {
    YouWin = 1;
}

But some variation is indefinitely allowed, especially in spacing and line breaks.


Title: Re: Game Maker Help Thread!
Post by: TyrOvC on November 10, 2012, 09:57:40 AM
Gamemaker allows pretty (ugly) loose coding.

if(this=that){

}

would set this = that and continue if this=that=true in most languages

but pretty sure in Gamemaker it parses a single = inside an if statement as equivalent to ==


Random stuff gamemaker accepts:
Code:
var avariable  //no semicolon
avariable=1 //gamemaker doesn't require semicolons :(
if avariable = 1{killSomething();breakSomething();}
else if avariable
{
   die();
}

if(avariable){    
//this statement is executed because in Gamemaker the true boolean is equal to 1
    rage();
}
Just because you can make code that looks like that, doesn't mean you should.


Title: Re: Game Maker Help Thread!
Post by: Nathan on November 10, 2012, 11:21:45 AM
I agree loose coding is annoying, but if it works without why do other engines reject it?


Title: Re: Game Maker Help Thread!
Post by: Urza on November 10, 2012, 02:03:04 PM
I agree loose coding is annoying, but if it works without why do other engines reject it?
One reason is that incorrect syntax for something common might overlap with a valid syntax for something unusual. Like TyrOvC said, if (this=that) does have a legitimate (but strange) meaning in C. I can't immediately think of a case where a missing semicolon would be ambiguous, but it wouldn't surprise me if there is one.


Title: Re: Game Maker Help Thread!
Post by: Nathan on November 10, 2012, 02:53:05 PM
A semi-colon may be hurtful if the cpu doesn't recognize the end of a line as a break


Title: Re: Game Maker Help Thread!
Post by: Wonkyth on November 10, 2012, 06:04:55 PM
A non-issue, as this will only make it incomprehensible to a compiler/interpreter.


Title: Re: Game Maker Help Thread!
Post by: Nathan on November 11, 2012, 08:48:59 PM
Does anyone think programming will be obsolete in 10-20 years. I mean a lot of drag and drop programs are being made...


Title: Re: Game Maker Help Thread!
Post by: Urza on November 11, 2012, 10:09:42 PM
The interface doesn't really matter so much. Whether you do it by typing individual opcodes or dragging little widgets together, you still have to input the logic of what you want it to do somehow.


Title: Re: Game Maker Help Thread!
Post by: Nathan on November 12, 2012, 03:22:41 PM
The interface doesn't really matter so much. Whether you do it by typing individual opcodes or dragging little widgets together, you still have to input the logic of what you want it to do somehow.

Yes but would it be wise to major in it when it may be super easy in the future?


Title: Re: Game Maker Help Thread!
Post by: Urza on November 13, 2012, 12:40:12 AM
Hard to say. But no matter how easy it gets a person with skills will always have an advantage. Of course you don't have to get those skills in school necessarily. But if you think it's what you want to do for a living, it probably still makes as much sense for a major as anything else.


Title: Re: Game Maker Help Thread!
Post by: Nathan on November 13, 2012, 12:19:15 PM
Ya. And I can't see how the widgets will get that advanced!


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on November 25, 2012, 04:51:45 AM
So I'm making a little game, and I find myself useing the line when dealing with  inventory for making you pick up say, a dagger (If slot one is active, then dagger goes in slot one
"if global.vCurrentSlot = 1 then global.INVSLOT1 = 1
if global.vCurrentSlot = 2 then global.INVSLOT2 = 1
if global.vCurrentSlot = 3 then global.INVSLOT3 = 1
if global.vCurrentSlot = 4 then global.INVSLOT4 = 1"

A fair bit, or something like it, is there any way to clean this up/ make it work so that I can have more  inventory spaces with out adding more to that line?



Title: Re: Game Maker Help Thread!
Post by: Moloch on November 25, 2012, 06:42:08 AM
Arrays or GM's built in data structures (ds_list = 1d array, ds_grid = 2d array).

initialize array at start of game:
global.invSlots[0] = 0;
global.invSlots[1] = 0;
global.invSlots[2] = 0; etc... just use a 'for' loop.

put dagger in current slot:
global.invSlots[global.vCurrentSlot] = 1


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on November 25, 2012, 12:45:51 PM
I have no clue how to do that, but I'll look it up

Edit: looking it up is being very helpful so far

I am so far over my head.


Title: Re: Game Maker Help Thread!
Post by: Moloch on November 25, 2012, 05:20:17 PM
You've probably found better explanations than I could give, but it helps to visualize the array as a spreadsheet. So global.invSlots would be spreadsheet with 1 row, and the number in the [] brackets refers to each cell. Since it starts at 0, global.invSlots[0] would be inventory slot 1.
Once you get that down you can define your inventory slots (and another for all the items) with a 2d array.


Title: Re: Game Maker Help Thread!
Post by: Nathan on November 26, 2012, 02:16:34 AM
Is it easy to draw an array?


Title: Re: Game Maker Help Thread!
Post by: TyrOvC on November 26, 2012, 05:10:14 PM
Is it easy to draw an array?
You can do all sorts of things with arrays and a way of iterating over them (for or while loops).

Say you have an array holding an inventory, that can hold any number of items.

You have one variable that you keep track of the length of the array in (one of gamemaker's failings, there isn't an easy way to check the length of an array, if I recall right). To go through everything in the array, you could do

Code:
numberofitems; //local variable you update with how many items there are

var i;
for(i=0;i<numberofitems;i++){//Each time we go through this loop, i is incremented by 1. The loop stops when i equals the number of items. Arrays are 0 index, so you might have to change the i<numberofitems logic a bit depending on how you're doing the numberofitems
  inventory[i]; //access this inventory slot
}

to iterate over the whole inventory.

To draw the inventory, you could do something like
Code:
//numberofitems is a local variable you update with how many items there are

var i, xdraw, ydraw;
xdraw=60; //Start drawing at sixty x from the left
ydraw=12; //Start our first row at twelve pixels from the top
for(i=0;i<numberofitems;i++){
  draw_item(xdraw,ydraw,inventory[i]); //Say we have a script that accepts the coordinates to draw an item at, and translates whatever format we're storing are items in the inventory array as to a sprite
  xdraw+=16; //the next item we draw will be moved over sixteen pixels
  if(i mod 5==0){//Every five items, let's start drawing more items on a new row
      ydraw+=12; //Draw the next items lower down
      xdraw=60; //Reset the x drawing to the first column's position
  }
}
That pseudo-code logic will draw the inventory to the screen looking something like
[item] [item] [item] [item] [item]
[item] [item] [item] [item] [item]
[item] [item]

There's more streamlined ways of doing it without the temporary xdraw and ydraw variables for the drawing position, using just math, but that's an example with easier to follow logic (I think).



A good example would be the tab function I coded for the Tastes Like Spelunky level editor that gives a nice selectable list of every item in the editor on one screen (and I think it was copied over pretty much the same to Editor+ too now), if you want to look at one of those sources. Can't remember where any of that was now though, so you'd have to search.


Title: Re: Game Maker Help Thread!
Post by: Nathan on November 26, 2012, 05:23:17 PM
Thanks! One thing I have been wondering. How do you calculate slopes in a platform game?


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on November 27, 2012, 12:47:09 AM
Code:
[quote author=TyrOvC link=topic=586.msg67486#msg67486 date=1353971414]
[
var i;
for(i=0;i<numberofitems;i++){//Each time we go through this loop, i is incremented by 1. The loop stops when i equals the number of items. Arrays are 0 index, so you might have to change the i<numberofitems logic a bit depending on how you're doing the numberofitems
  inventory[i]; //access this inventory slot
}
[/quote]
don't you have to say i = 0 first?


Title: Re: Game Maker Help Thread!
Post by: Wonkyth on November 27, 2012, 01:03:27 AM
Thanks! One thing I have been wondering. How do you calculate slopes in a platform game?
What do you mean by 'calculate'?
If you mean the maths for calculating the angle of a slope, I'm sure you can manage that yourself. If you mean something else, well, explain. :P


Title: Re: Game Maker Help Thread!
Post by: Nathan on November 27, 2012, 12:56:41 PM
I mean calculating the angle of a slope and adjusting the players sprite and movement to tackle it. I am good at math but have trouble implementing it into games.


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on November 27, 2012, 11:40:20 PM
Does anything know anything about grid based AI of monsters?


Title: Re: Game Maker Help Thread!
Post by: Moloch on November 28, 2012, 12:11:02 PM
Does anything know anything about grid based AI of monsters?

Not really, but look up "A-Star" or "A*" pathfinding for a start.


Title: Re: Game Maker Help Thread!
Post by: Nathan on November 30, 2012, 12:02:10 AM
Anything on my slopes. I am not asking for code but rather how I could implement it and what I would need to calculate.


Title: Re: Game Maker Help Thread!
Post by: halibabica on November 30, 2012, 05:29:17 AM
I dunno if it'll help much, but Spelunky DOES have a slope-calculating code in it. It's used exclusively for the sides of Olmec's head as far as I know, but it allows Spelunker to move up and down the curve without any trouble. And if you need a sprite to change angle when it moves along the slope or something, try looking at the arrow's code for how it turns around.


Title: Re: Game Maker Help Thread!
Post by: Wonkyth on November 30, 2012, 07:03:27 AM
The standard hack is just to keep checking if the collision box is within the slope, and move it up a pixel etc until it is no longer. Works great if you can do pixel operations, but I'm not sure how GM is with that.


Title: Re: Game Maker Help Thread!
Post by: Nathan on November 30, 2012, 11:06:28 AM
I'll try that! Thanks


Title: Re: Game Maker Help Thread!
Post by: Nathan on December 05, 2012, 04:40:57 PM
How do you make a square root function in gamemaker? I need this equation to work in gamemaker.

[square root of(x2 - x1)2 + (y2 -  y1)2]



Thank in advance for any help

EDIT: its the distance formula if that helps


Title: Re: Game Maker Help Thread!
Post by: Urza on December 05, 2012, 07:19:58 PM
Square root is sqrt(x), but you probably want to use point_distance(x1,y1,x2,y2) in this case..


Title: Re: Game Maker Help Thread!
Post by: Nathan on December 05, 2012, 07:25:54 PM
DAMN SIMPLIFICATION! I WANTED TO FEEL GOOD WHEN I APPLIED ALGEBRA TO MY GAMES NOT HAVE A COMPUTER DO IT FOR ME!


Title: Re: Game Maker Help Thread!
Post by: Nathan on December 05, 2012, 08:51:41 PM
Okay so I'm working on a top down spaceship shooter (same view as asteroids) and wanted an enemy to shoot a projectile at the direction where the player is if it's within a certain range. I know how to calculate lines/slopes but want to make sure there isn't a 2-5 line way to do it first! Please don't let there be! I want to challenge myself


Title: Re: Game Maker Help Thread!
Post by: Wonkyth on December 05, 2012, 11:40:01 PM
fwiw, it's nearly always better to work in squared distances anyway. Unless you need to literally write the actual distance in human readable terms, it's better to square other values to make comparisons. Finding square roots is rather CPU intensive, relatively speaking.


Title: Re: Game Maker Help Thread!
Post by: Urza on December 06, 2012, 01:29:08 AM
point_direction(x1,y1,x2,y2) Returns the direction from point (x1,y1) toward point (x2,y2) in degrees.

Sorry.

I know how you feel. One time I got to use trig in a Morrowind mod (Chalk, in case any one plays that), and felt pretty proud of myself. "Luckily" Morrowind scripting doesn't have any advanced math features.


Title: Re: Game Maker Help Thread!
Post by: Moloch on December 06, 2012, 04:37:17 AM
One time I got to use trig in a Morrowind mod (Chalk, in case any one plays that), and felt pretty proud of myself. "Luckily" Morrowind scripting doesn't have any advanced math features.

You made the chalk mod? Sheeeeeeit. It was an 'essential' mod in my list.


Title: Re: Game Maker Help Thread!
Post by: Nathan on December 06, 2012, 11:56:18 AM
point_direction(x1,y1,x2,y2) Returns the direction from point (x1,y1) toward point (x2,y2) in degrees.

Sorry.

I know how you feel. One time I got to use trig in a Morrowind mod (Chalk, in case any one plays that), and felt pretty proud of myself. "Luckily" Morrowind scripting doesn't have any advanced math features.

DAMN! Well its okay. It just makes it easier I guess...


Title: Re: Game Maker Help Thread!
Post by: Wonkyth on December 07, 2012, 01:46:20 AM
Study dat maths, mon! :D


Title: Re: Game Maker Help Thread!
Post by: Nathan on December 07, 2012, 09:57:42 AM
I WANT TO! AHHHHHHH! STOP HAVING MATH FUNCTIONS GAME MAKER


Title: Re: Game Maker Help Thread!
Post by: Wonkyth on December 07, 2012, 08:53:13 PM
Simple: Stop using Game Maker, and get ye into them matrices! :D


Title: Re: Game Maker Help Thread!
Post by: IFapToYourSister on December 07, 2012, 09:01:43 PM
Stop using Game Maker,
http://www.youtube.com/watch?v=07So_lJQyqw


Title: Re: Game Maker Help Thread!
Post by: Nathan on December 07, 2012, 09:30:07 PM
But game maker is the best tool out there D:


Title: Re: Game Maker Help Thread!
Post by: Wonkyth on December 07, 2012, 09:33:53 PM
Well, No.
Also there's other non-tools which work just fine, if they take a little more effort. Go learn SDL or something. ;)


Title: Re: Game Maker Help Thread!
Post by: Nathan on December 07, 2012, 10:09:33 PM
The effort/product ratio is amazing though!


Title: Re: Game Maker Help Thread!
Post by: KarjamP on December 08, 2012, 01:20:10 AM
GameMaker is a legitimate game engine.

I know a few great games that was made with it that are great:

Iji and other Remar games, and
Spelunky


Title: Re: Game Maker Help Thread!
Post by: Moloch on December 08, 2012, 09:02:29 AM
GameMaker is a legitimate game engine. I know a few great games that was made with it that are great:

Who's mouth are you putting words in now? No one said it wasn't a legitimate game engine or that great games can't be made with it. Wonkyth is just pointing out that if you're using a tool like GM you're not going be forced to advance your maths/coding skills in certain areas because most of the functions you'll need are already done for you.

I will add to your sad attempt of listing 'legitimate' GM games, though:

Super Crate Box (Steam)
Serious Sam: The Random Encounter (Steam)
Legend of Fae (Steam)
Wanderlust: Rebirth (Steam, Desura, Gamersgate)
Hotline Miami (Steam, GOG)


Title: Re: Game Maker Help Thread!
Post by: Nathan on December 08, 2012, 06:55:17 PM
The only reason I would switch would be if I wanted to make a game impossible to pull 
off in gm. Like a 3d game


Title: Re: Game Maker Help Thread!
Post by: KarjamP on December 09, 2012, 12:39:59 AM
Who's mouth are you putting words in now? No one said it wasn't a legitimate game engine or that great games can't be made with it.

Well, that's how I had interpreted his post by the time I did that post. :P


Title: Re: Game Maker Help Thread!
Post by: Wonkyth on December 09, 2012, 07:21:21 AM
The only reason I would switch would be if I wanted to make a game impossible to pull 
off in gm. Like a 3d game
From memory, you can do 3D in Game Maker. :P
Personally I abandoned it because I wanted to be able to have a lot of objects without the runtime engine dying FPS death.


Title: Re: Game Maker Help Thread!
Post by: Urza on December 09, 2012, 11:08:46 AM
Super Crate Box (Steam)
Serious Sam: The Random Encounter (Steam)
Legend of Fae (Steam)
Wanderlust: Rebirth (Steam, Desura, Gamersgate)
Hotline Miami (Steam, GOG)
Obviously those don't count because they're all Steam games and DRM is never "legitimate".


Title: Re: Game Maker Help Thread!
Post by: Nathan on December 09, 2012, 02:25:04 PM
The only reason I would switch would be if I wanted to make a game impossible to pull 
off in gm. Like a 3d game
From memory, you can do 3D in Game Maker. :P
Personally I abandoned it because I wanted to be able to have a lot of objects without the runtime engine dying FPS death.

It does have 3d but it sucks. I mean you can only import 3d objects from Anim8or if I remember correctly and it is mostly 2d functions they try to apply to 3d games


Title: Re: Game Maker Help Thread!
Post by: Nehemek on January 14, 2013, 06:02:19 PM
For 3d there is something called u3d, you can make a game with graphics like ps3 games, the only limitation with it is your computer : P.


Title: Re: Game Maker Help Thread!
Post by: Nathan on January 14, 2013, 09:58:28 PM
I thought you meant some sort of game maker plug-in at first :D. And yes Unity is my favorite. My friend uses it for everything. Even 2d


Title: Re: Game Maker Help Thread!
Post by: Damsel on January 20, 2013, 12:59:56 PM
Hello!

Yes, I already need help.

I am having trouble locating the code in the Spelunky source regarding Spelunkyman's hitbox. Since the monkey sprite is smaller I need to adjust it.

Thanks!


Title: Re: Game Maker Help Thread!
Post by: halibabica on January 20, 2013, 01:07:38 PM
I'm pretty sure his hit detection is governed by the box you set on the sprites themselves, which is kinda funny because that's the opposite of everything else in the game. I remember I had to tweak the ManTrap hit boxes in TLS, and that was how I did it.


Title: Re: Game Maker Help Thread!
Post by: Damsel on January 20, 2013, 01:14:18 PM
I tried editing the sprite's collision mask before posting. Unfortunately, my monkey is embedded in the ground at all times.

(http://i.imgur.com/xgDNohZ.png)


Title: Re: Game Maker Help Thread!
Post by: Moloch on January 20, 2013, 01:33:07 PM
In the properties menu for your monkey player sprites, there is the x/y origin settings. Click the "Center" button. The player uses the center of the sprite for positioning instead of top left corner.


Title: Re: Game Maker Help Thread!
Post by: Damsel on January 20, 2013, 01:43:04 PM
Thank you very much! Worked like a charm.


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on April 12, 2013, 10:27:03 AM
So hey, I want to unlock other thens with a short cut, what variables control that?


Title: Re: Game Maker Help Thread!
Post by: Nathan on April 12, 2013, 12:18:20 PM
What do you want to control? I assume thens was a typo


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on April 13, 2013, 10:27:43 PM
What do you want to control? I assume thens was a typo

I want unlocking shortcuts to unlock more then shortcuts. (make ladders appear on the title screen)


Title: Re: Game Maker Help Thread!
Post by: Nathan on April 14, 2013, 12:30:14 AM
Did you check tunnel man code? It seems like it would be there.


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on April 14, 2013, 02:02:31 AM
Did you check tunnel man code? It seems like it would be there.

You would think, but I can't find it


Title: Re: Game Maker Help Thread!
Post by: Nathan on April 14, 2013, 02:30:33 AM
Ah. Its probably in a script. Ill look for it myself and see what I can find.


Title: Re: Game Maker Help Thread!
Post by: hyperme on April 14, 2013, 03:09:14 AM
highscores, also check oTitle I think?


Title: Re: Game Maker Help Thread!
Post by: halibabica on April 14, 2013, 05:22:05 AM
Yeah, the tunnel man is regulated through highscores, and the shortcuts appear when the scores reach a certain number. If you wanted to have more shortcuts, you'd have to tweak those. Derek figured out a way to use the same score twice to make the L13 shortcut, but I could never wrap my brain around it.


Title: Re: Game Maker Help Thread!
Post by: Urza on April 14, 2013, 10:51:01 AM
I know exactly what you mean. I first looked at that and huh?! But I think I understand now, although I have no idea why he did it this way.

There are two global variables tunnel1 and tunnel2. And they work together like this:
1 is true, 2 is true > No shortcuts.
1 is false, 2 is true > One shortcut.
1 is true, 2 is false > Two shortcuts.
1 is false, 2 is false > Three shortcuts.
Perhaps the weirdest part of all this is that they start true and turn false as you unlock shortcuts.


Title: Re: Game Maker Help Thread!
Post by: Nathan on April 14, 2013, 11:15:49 AM
I don't think he wants more shortcuts, just wants them being triggered to add more stuff. That being Sao those are the variables to look at. If you did want a 4th shortcut then add an other Boolean. And why didn't he just do:

Shortcut1=true/false
Shortcut2=true/false
Shortcut3=true/false


Title: Re: Game Maker Help Thread!
Post by: halibabica on April 14, 2013, 12:54:56 PM
I have no idea why he did it this way.

...

Perhaps the weirdest part of all this is that they start true and turn false as you unlock shortcuts.
Ohhh, so that's how it works. I know why he used this method, though. It's because high scores are the only hard-coded numbers Game Maker keeps track of. Tunnel 1 and Tunnel 2 are the two lowest scores on the high score chart, and when they're depleted by your payments to the tunnel man, they cause shortcuts to appear.


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on April 14, 2013, 04:09:07 PM
I have no idea why he did it this way.

...

Perhaps the weirdest part of all this is that they start true and turn false as you unlock shortcuts.
Ohhh, so that's how it works. I know why he used this method, though. It's because high scores are the only hard-coded numbers Game Maker keeps track of. Tunnel 1 and Tunnel 2 are the two lowest scores on the high score chart, and when they're depleted by your payments to the tunnel man, they cause shortcuts to appear.

So I should have if score < X number, this object doesn't destroy itself?

would that work? (The ladders I want on the title screen)



Title: Re: Game Maker Help Thread!
Post by: halibabica on April 14, 2013, 05:15:01 PM
More like "if score is < X, instance create". It's easier to create objects rather than have them destroy themselves..


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on April 14, 2013, 06:13:39 PM
More like "if score is < X, instance create". It's easier to create objects rather than have them destroy themselves..

Really because I'm lazy and it seems easier that way

Where do I find what scores unlock what?


Title: Re: Game Maker Help Thread!
Post by: Urza on April 14, 2013, 06:16:05 PM
Ohhh, so that's how it works. I know why he used this method, though. It's because high scores are the only hard-coded numbers Game Maker keeps track of. Tunnel 1 and Tunnel 2 are the two lowest scores on the high score chart, and when they're depleted by your payments to the tunnel man, they cause shortcuts to appear.
Oh yeah, huh. I forgot they weren't just true/false but also held the progress towards buying each shortcut. That actually does make sense... kinda.

So I should have if score < X number, this object doesn't destroy itself?

would that work? (The ladders I want on the title screen)
No, it would be easier to check global.tunnel1 and global.tunnel2 instead. So it would work like this:
The first ladder destroys itself if tunnel1 and tunnel2 are greater than zero.
The second ladder destroys itself if tunnel2 is greater than zero.
The third ladder destroys itself if tunnel1 or tunnel2 is greater than zero.

P.S. I realized I accidentally swapped the middle two conditions in my first explanation, I have fixed it now.


Title: Re: Game Maker Help Thread!
Post by: halibabica on April 14, 2013, 08:42:04 PM
Having objects destroy themselves can create all kinds of unwanted problems. It might be easier in this case, but in general I'd say it's ill-advised.


Title: Re: Game Maker Help Thread!
Post by: marsgreekgod on April 15, 2013, 07:38:21 PM
Having objects destroy themselves can create all kinds of unwanted problems. It might be easier in this case, but in general I'd say it's ill-advised.

I would need an object to create them...

I'll test it out in a second copy

Ohhh, so that's how it works. I know why he used this method, though. It's because high scores are the only hard-coded numbers Game Maker keeps track of. Tunnel 1 and Tunnel 2 are the two lowest scores on the high score chart, and when they're depleted by your payments to the tunnel man, they cause shortcuts to appear.
Oh yeah, huh. I forgot they weren't just true/false but also held the progress towards buying each shortcut. That actually does make sense... kinda.

So I should have if score < X number, this object doesn't destroy itself?

would that work? (The ladders I want on the title screen)
No, it would be easier to check global.tunnel1 and global.tunnel2 instead. So it would work like this:
The first ladder destroys itself if tunnel1 and tunnel2 are greater than zero.
The second ladder destroys itself if tunnel2 is greater than zero.
The third ladder destroys itself if tunnel1 or tunnel2 is greater than zero.

P.S. I realized I accidentally swapped the middle two conditions in my first explanation, I have fixed it now.
Ok thanks I'll let you know how it goes


Title: Re: Game Maker Help Thread!
Post by: halibabica on April 16, 2013, 04:36:54 AM
You can do it in the Create event of the room objects; in this case, oTitleScreen.


Title: Re: Game Maker Help Thread!
Post by: IFapToYourSister on April 21, 2013, 07:25:40 PM
So in my mod you have always have a weapon. This weapon can be charged up for more powerful shots. I have an image of the charge shot in the hud and I want some numbers to be next to the image. I have the numbers part done, but how do I make it so the numbers go up everytime the player charges up? (The numbers are to show what level of charge his wep is at)
Edit: Never mind I figured it out.


Title: Re: Game Maker Help Thread!
Post by: IFapToYourSister on April 22, 2013, 03:01:06 PM
How do I make a new door on the title screen? Like a functioning door that shows the "walking in door" animation.


Title: Re: Game Maker Help Thread!
Post by: Urza on April 22, 2013, 07:20:03 PM
How do I make a new door on the title screen? Like a functioning door that shows the "walking in door" animation.
It's probably better to take a look how existing doors work than me try to explain it completely, but the basic idea is you make a new object with oXStart as a parent. All the actual code is on the oPlayer1 sprite. You'll need to edit code in three places. The Create event, the "Action" section of the Step event, and the Animation End event. Search for xtutorial in each case to find the relevant code.


Title: Re: Game Maker Help Thread!
Post by: hyperme on April 23, 2013, 09:15:29 AM
How do I make a new door on the title screen? Like a functioning door that shows the "walking in door" animation.

Hey I made a thing about that! Linky (http://mossmouth.com/forums/index.php?topic=1135.0)


Title: Re: Game Maker Help Thread!
Post by: IFapToYourSister on April 23, 2013, 12:43:41 PM
1000 thanks Hyper! But I already figured that out before you sent it, but thanks anyway. Now I'm having problems with the room it's supposed to send you to. It's all zoomed in, I used the exact same views as the Highscore room.


Title: Re: Game Maker Help Thread!
Post by: halibabica on April 23, 2013, 01:35:08 PM
You have to set different views for custom rooms. I had to do it when I made the Custom Start Chamber for TLS, but it's been so long I can't remember how I did it. :S


Title: Re: Game Maker Help Thread!
Post by: Moloch on April 24, 2013, 07:55:08 AM
Look in the Create event for oScreen, the last piece of code in the list, there is a bunch of room_set_view stuff - add one for your new room.


Title: Re: Game Maker Help Thread!
Post by: IFapToYourSister on April 24, 2013, 02:10:35 PM
Fuck yes! This worked :D
Thank you Moloch!


Title: Re: Game Maker Help Thread!
Post by: HaydenDavenport on May 09, 2013, 05:39:17 PM
Hey everyone!

I'm pretty new to game maker. I'm not that new to Spelunky though.

Anyways, I opened the source code and was completely baffled and perplexed by the amount of stuff that it takes to make a game.

It's time for me to start learning (and to show my naivety..).

As I learn, I may make mods for Spelunky, and I will be starting my own little dinky game.

But for starters, where is the character movement for our favorite little spelunker? I looked everywhere in oPlayer1, and everywhere else logical that I could think of but I have no idea where his movement properties are in the code.

Could anyone help me? It's probably fairly obvious, but I am close to a complete noob. I have a long way to go but I am determined to learn! :D


Title: Re: Game Maker Help Thread!
Post by: Nathan on May 09, 2013, 06:13:14 PM
It's in the section called scripts. There is a folder within the scripts called engine or something similar. Inside that is the physics and controls/movement in the game. Feel free to ask any more questions


Title: Re: Game Maker Help Thread!
Post by: Urza on May 09, 2013, 08:18:05 PM
The way Spelunky does it is probably not the way you'd want to do it for a simple game made from scratch. Because it uses that platform engine thing it gets fairly complicated.

The actual code for moving and stuff is broken up between a script called "characterStepEvent" in the Platform Engine folder, and the actual step even of oPlayer1. Both of those call the scripts in the Control folder, which all have names starting with "check" (e.g. "checkLeftPressed). And because the game uses remappable controls, those scripts refer to variables which are set by scrInit (not in a folder). Whew.


Title: Re: Game Maker Help Thread!
Post by: Nathan on May 09, 2013, 10:16:18 PM
if your making a simple game, I can give you some easy movement code


Title: Re: Game Maker Help Thread!
Post by: HaydenDavenport on May 10, 2013, 12:46:09 AM
Thanks for the quick replies!

I completely forgot that Spelunky used Martin Piecyk's engine...

Hm..

I'm not quite a noob, but I'm only a step above it. I have made really lame games in game maker before, and have dabbled with coding. So I know the very basic stuff. At the very least I could easily figure out how to get solid character movement, collisions, weapons, etc.

I followed Derek's tutorials on Game Maker and was able to go "above-and-beyond" by the time I finished. In other words, I understood what I was doing enough to add more to it.

If I have the help of the community here and the communities elsewhere, do you think I could handle figuring out the Basic Platform Engine at my current level? I'm 20 if that matters at all.

My game won't be a huge deal likely, but I am planning on putting a great deal of thought into it. Put into vague terms, I am going for a platformer, a rouge-like even. But I am focusing on a unique mechanic, a different style of randomized levels (More.. "Open-World"), and a very different feel/mood.


Title: Re: Game Maker Help Thread!
Post by: Nathan on May 10, 2013, 10:27:50 AM
Go for it. Ill personally answer any questions you have along the way.


Title: Re: Game Maker Help Thread!
Post by: Moloch on May 10, 2013, 10:57:19 AM
If I have the help of the community here and the communities elsewhere, do you think I could handle figuring out the Basic Platform Engine at my current level?
You can do it. If you looking to use a platform engine, another one for Gm you might want to check out is the Grandma Engine.


Title: Re: Game Maker Help Thread!
Post by: HaydenDavenport on May 11, 2013, 01:52:25 AM
Thanks guys! I really appreciate the encouragement. I was sort of expecting, "Ehh... You should probably hold off for like a year before attempting anything with an engine."

Are there any tutorials you guys recommend for someone of my level? I eventually need to be able to randomize terrain to a certain degree, so if there is anything like that around please let me know!

Also, any other engine recommendations? I had a look at Grandma's Engine. I *think* Martin's engine is a better fit, especially since I'm not after slopes and fancy things of that nature. But I will look into it more. Eddy's Platform Engine also looks like it has some good features, as does Bebop's Platformer Engine... Lol, I guess I should just pick one and roll with it?


Title: Re: Game Maker Help Thread!
Post by: Nathan on May 11, 2013, 02:54:25 PM
Yep :P. And there are many types of randomization, if you could be more specific of how/what you want to randomize, I could help you write the code.


Title: Re: Game Maker Help Thread!
Post by: HaydenDavenport on May 12, 2013, 12:50:32 AM
Thank you very much!

Hmm.. I'll try to be as descriptive as possible despite my lack of appropriate terms.

And this may not even be possible, in which case I would need to completely rethink this game.

This game will likely give the player a larger room size than spelunky in order to maximize strategic gameplay. The game would have an upper and lower limit, (a floor and a ceiling plus whatever floating platforms might lie between.) but no horizontal (left and right) walls.

The game would start in a particular type of area or "biome" (I hesitate to use that word since it would be a more specific and specialized area than just a generic biome.)

From there, I would like the game to completely be randomized as you play. In other words, moving left generates new areas, and moving right generates new areas. Furthermore, I would want everything off screen to be deleted, so that if you leave a place and come back it will be gone forever.

With a larger screen size, I hope to allow for players to strategically play the game in a vertical fashion. (The gameplay will cater to this as well.. Hopefully.) In other words, terrain above and below you won't be randomly generated since it stays on the screen as long as you don't move too far away from it.

Finally, and without revealing too much, there will be a way for players to unlock new terrains, which I would like to gain the chance to randomly generate after specific requirements have been met.

Obviously there will be more to it than that, such as minimum sizes an area should be before it can change to a different area.

--------------------------------------------------------------------------------

I don't know how the randomly generated stuff in Spelunky works, but I think "chunks" might be a good way to go. Similar to Minecraft but more planned.. with the option for prearranged "chunks" of data to be randomly assigned based on various parameters.

Has that made sense?

I wouldn't want to ask anyone to entirely write the code for me because this seems like quite the undertaking. But I will take all of the advice I can get! Thanks again!

Also, unrelated, do you play Team Fortress 2, Nathan? I love that game! :D


Title: Re: Game Maker Help Thread!
Post by: Moloch on May 12, 2013, 08:09:19 AM
There's a technique for faking an 'endless' room by keeping the player at the center of the screen (the actual room is slightly larger than the screen view, with enough space outside the visible play area that you can generate new 'chunks' off-screen) and moving the world around the player, or using an offset to change the position that the world is drawn at based on which direction the player moves. This would be ideal for the game you're describing. I hope that is enough for you to find more information somewhere, as i haven't tried it yet myself.
If the player can only travel left and right, maybe seeing how 'endless runner' games that are popular on mobile devices are generated...but in your case you can travel left or right at will instead of being forced in only one direction.


Title: Re: Game Maker Help Thread!
Post by: Nathan on May 12, 2013, 09:37:33 AM
Yes I do play TF2! Anyways, Spelunky arranges levels by randomly linking together pre arranged rooms. Its a bit more complicated than that but thats the jist of it. And never say "This might not be possible", because there is a way to do almost anything with programming. Deleting what is offscreen would be super simple in game maker, and randomizing terrain would not be that hard. What would be slightly difficult is making sure it is physically possible to beat each level. Spelunky gave ropes and bombs as items in the beginning solely because you needed them to beat some levels in earlier versions of the game. Maybe you could have something like this? Anyways I recommend just starting on the game and when you need the randomization code just pm me and I can help write large portions of it for you :).


Title: Re: Game Maker Help Thread!
Post by: HaydenDavenport on May 12, 2013, 03:21:29 PM
There's a technique for faking an 'endless' room by keeping the player at the center of the screen (the actual room is slightly larger than the screen view, with enough space outside the visible play area that you can generate new 'chunks' off-screen) and moving the world around the player, or using an offset to change the position that the world is drawn at based on which direction the player moves.

That sounds exactly like what I am looking for! Hopefully I can find more about that on the gamemaker forums or something. :D

Yes I do play TF2!

Haha, awesome! I figured because of your icon. It's so fun! :P

And never say "This might not be possible", because there is a way to do almost anything with programming.

That's awesome to know. I always fear that Game Maker will show its limitations, but it is already proving itself to be a worthy force for game designers.

What would be slightly difficult is making sure it is physically possible to beat each level. Spelunky gave ropes and bombs as items in the beginning solely because you needed them to beat some levels in earlier versions of the game. Maybe you could have something like this?

Yup! I have already given that some thought. I have some ideas, but I won't know if they will be successful until I have a playable version of the game. For starters, my character's jump height will probably be a bit greater than Spelunky's main character. I wish I had thought of grabbing ledges as a mechanic, because that was a unique idea for a platformer. It's also a large part of what makes Spelunky gameplay unique so I don't want to take it. (Unless I think of a unique way to implement it.)

Also, with terrain that generates on either side of the character, I'm hoping that players will be able to erase any situations that they get stuck in. Obviously there will be exceptions though, and I plan to address them.

Anyways I recommend just starting on the game and when you need the randomization code just pm me and I can help write large portions of it for you :).

Thank you. That is very kind. I will definitely be around this forum as I work on the game. (And the main Game Maker forum.. And game design forums, etc.)

I have already started on my game, but I am holding off a bit until I decide on what engine I want. I'm still leaning toward the engine used in Spelunky, but I'm not 100% sure. I wish they had lists of everything included but I guess I could easily just choose one and edit it for my needs.


Title: Re: Game Maker Help Thread!
Post by: Nathan on May 12, 2013, 03:44:08 PM
Honestly, for what your doing, I would suggest starting from scratch. I can send you my movement/collision code for a game I was workin on a while back if you want.


Title: Re: Game Maker Help Thread!
Post by: HaydenDavenport on May 13, 2013, 01:33:20 AM
Honestly, for ehat your doing, I would suggest starting from scratch. I can send you my movement/collision code for a game I was workin on a while back if you want.

I'll certainly take a look at it if you PM me, thank you!

I'm currently trying to figure out the basic character movement from Martin Piecyk's engine. (The Engine used in Spelunky.)
But I'm a bit confused. Hopefully someone can enlighten me. If you look at the characterStepEvent script in the code, then go to the comment that says "//allows the character to run left and right" you will see xAcc and xVel. Obviously those stand for the Acceleration and Velocity for the x axis, but I have no idea where they are assigned values unless xAcc-=runAcc automatically assigns 0 to xAcc in GML. (Is there some way you can see what value a variable has been assigned? Like a keyboard shortcut or something?)

Secondly, there are two things I am trying to figure out how to do with my character's movement. I need to figure out how to test if a direction was just pressed and I will be able to solve both. I'll give an example.

Lets say you have basic left and right movement with acceleration and friction variables.
If a character presses right they have an acceleration period. Then when the player lets go of right they experience a short period of friction before halting. Here is some basic code to illustrate that.. Please let me know of any "grammatical" errors/unconventional things you see in my code. Technically this is my first time coding something on my own and I need to learn to code properly so that myself and others can read it efficiently.

Quote from: Code
//left
if (keyboard_check(vk_left)) {
    leftPressed = true;
    hspeed -= 4;
    }
else leftPressed = false;

//right
if (keyboard_check(vk_right)) {
    rightPressed = true;
    hspeed += 4;
    }
else rightPressed = false;

if (speed > 6) speed = 6;

//Applys friction without affecting speed like game maker's standard friction
//if there is a better way to do this next part, please let me know
if (leftPressed = false && rightPressed = false && (hspeed > 0 or hspeed < 0)) {
    if (hspeed < 0) hspeed += 0.5;
    if (hspeed > 0) hspeed -= 0.5;
    }

With this code, if the player moves right they will move right as expected. If the player suddenly switches directions then they will begin the same period of acceleration as normal, then be off on their way in a new direction. Instead of that, if right was just pressed, I would like there to be no period of acceleration if changing directions. I want the player to instantly be going left at full speed. I have a quick-fix solution for it right now, but ideally I would like to be able to test if a specific button was just pressed within a fraction of a second.

Here is my quick-fix for moving left from right:
Quote from: Code
//left
if (keyboard_check(vk_left) && speed >= 3) hspeed = -6;
if (keyboard_check(vk_left)) {
    leftPressed = true;
    hspeed -= 4;
    }
else leftPressed = false;


Title: Re: Game Maker Help Thread!
Post by: Nathan on May 13, 2013, 10:16:29 AM
Well you could set a timer when they release the left key that stops when the right key is hit. What you would need to do is start a timer counting up when the left key is released. You can't do this with the alarm function easily so I suggest making a timer in the step event. If it is less than a certain number when the right key is pressed then the player should move at the speed he was previously moving at. Otherwise he should start over on his acceleration.


Title: Re: Game Maker Help Thread!
Post by: HaydenDavenport on May 14, 2013, 02:14:54 PM
Well you could set a timer when they release the left key that stops when the right key is hit. What you would need to do is start a timer counting up when the left key is released. You can't do this with the alarm function easily so I suggest making a timer in the step event. If it is less than a certain number when the right key is pressed then the player should move at the speed he was previously moving at. Otherwise he should start over on his acceleration.

Ok, thanks. I'm not sure how to set a timer, or how to get the game to recognize when a key has been released... Lol...

What would the code look like for one of the keys?


Title: Re: Game Maker Help Thread!
Post by: Nathan on May 16, 2013, 09:16:23 PM
Not at CPU ATM. I'll give you code tomarrow.


Title: Re: Game Maker Help Thread!
Post by: IFapToYourSister on May 18, 2013, 02:26:34 PM
Need some help with character switching!
My code:
if keyboard_check_pressed(world.switchKey)
{
instance_change(player2,true);
}

switchKey is obviously stored in the world object, when I do this the player doesn't switch to the other character. His animation is restarted but that's all. He doesn't switch or anything. I put it in the Begin Step event. I also tried moving it to the Step event but the same happened.


Title: Re: Game Maker Help Thread!
Post by: Moloch on May 18, 2013, 03:12:52 PM
Do you have code in the Create event for player2 that sets the sprite/abilities/etc that make it unique from the other player objects? otherwise those variables may be carried over from player2...instance_change is a bit weird.


Title: Re: Game Maker Help Thread!
Post by: IFapToYourSister on May 18, 2013, 03:15:02 PM
Well you see, when I used the instance_destroy and instance_create ones the same thing happened with a few differences (player will stop in mid-air for a split second and will revert back to standing right)


Title: Re: Game Maker Help Thread!
Post by: Nathan on May 18, 2013, 03:42:08 PM
It's probably because of a structural differences between this engine and the old one you used


Title: Re: Game Maker Help Thread!
Post by: IFapToYourSister on May 18, 2013, 10:09:35 PM
Help me guys.


Title: Re: Game Maker Help Thread!
Post by: Moloch on May 19, 2013, 08:55:56 AM
I don't know. Could it be this issue?
http://gmc.yoyogames.com/index.php?showtopic=519560
Maybe test it by trying another way other than pressing a key to switch characters, like collision with an object that can only be triggered by a certain character.


Title: Re: Game Maker Help Thread!
Post by: IFapToYourSister on May 19, 2013, 09:17:38 AM
I don't know. Could it be this issue?
http://gmc.yoyogames.com/index.php?showtopic=519560
Maybe test it by trying another way other than pressing a key to switch characters, like collision with an object that can only be triggered by a certain character.

Okay I made it so if you touch a certain object you will switch characters. THAT WORKED FINE! This just doesn't work!


Title: Re: Game Maker Help Thread!
Post by: Moloch on May 19, 2013, 11:56:04 AM
Haven't tested this, but from what i understand  the instance replacing the old one is seeing keyboard_check_pressed as true during the same step so try an alarm or counter to disable the switchKey until the next step.

if keyboard_check_pressed(world.switchKey) and world.alarm[0] == 0
{
world.alarm[0] = 1;
instance_change(player2,true);
}



Title: Re: Game Maker Help Thread!
Post by: IFapToYourSister on May 19, 2013, 07:13:23 PM
Tried it. Still doesn't seem to switch. How about this: I send you the source and you help me? Just this once. Please I beg you. I really want to make a good game and this bug is standing in the way. Please


Title: Re: Game Maker Help Thread!
Post by: Moloch on May 20, 2013, 07:55:48 AM
Well ok, I'll look at it. Can't promise i'll figure it out :D


Title: Re: Game Maker Help Thread!
Post by: IFapToYourSister on May 20, 2013, 12:41:47 PM
Well ok, I'll look at it. Can't promise i'll figure it out :D
This is the GMK: http://www.mediafire.com/?viqzmj263j7d31e


Title: Re: Game Maker Help Thread!
Post by: IFapToYourSister on May 20, 2013, 08:10:40 PM
Okay guys I fixed it!


Title: Re: Game Maker Help Thread!
Post by: Moloch on May 21, 2013, 07:29:24 AM
Ok. I was gonna say, use the same method to switch characters from the first game if that works.


Title: Re: Game Maker Help Thread!
Post by: IFapToYourSister on May 21, 2013, 02:48:12 PM
Nah I just changed one of the things on the alarm. Also new bug. When player 2/player 3 jump and land they will be stuck in the ground. Please help :( (Check the source)


Title: Re: Game Maker Help Thread!
Post by: Nathan on May 21, 2013, 03:00:41 PM
Its probably just the collision masks. Take a look at all the sprites and see if one of their sprites has a mask that is too large or something.


Title: Re: Game Maker Help Thread!
Post by: IFapToYourSister on May 21, 2013, 03:03:54 PM
Its probably just the collision masks. Take a look at all the sprites and see if one of their sprites has a mask that is too large or something.
They all have the same masks and origins.


Title: Re: Game Maker Help Thread!
Post by: halibabica on May 21, 2013, 03:31:16 PM
Make sure the new players are set to be drawn the same way as the first. If they're drawn from different points on the sprite, then having the same origins is actually the problem.


Title: Re: Game Maker Help Thread!
Post by: IFapToYourSister on May 21, 2013, 03:52:11 PM
I use "instance_change" is that the problem?


Title: Re: Game Maker Help Thread!
Post by: Nathan on May 22, 2013, 10:50:06 AM
I don't know if instance_change is an official gm function or just an extension/addon


Title: Re: Game Maker Help Thread!
Post by: IFapToYourSister on May 22, 2013, 04:05:29 PM
Official function.


Title: Re: Game Maker Help Thread!
Post by: Nathan on May 23, 2013, 09:06:48 AM
are the sprites the same size?


Title: Re: Game Maker Help Thread!
Post by: IFapToYourSister on May 23, 2013, 12:48:03 PM
no


Title: Re: Game Maker Help Thread!
Post by: IFapToYourSister on May 23, 2013, 08:40:35 PM
Fixed it now


Title: Re: Game Maker Help Thread!
Post by: Nathan on May 24, 2013, 12:44:06 AM
What did you do to fix it?


Title: Re: Game Maker Help Thread!
Post by: HaydenDavenport on June 12, 2013, 05:56:07 AM
Hi again everyone.

I have a big question.

How does Spelunky handle random generation?
I need to understand how it works because my game is going to need to utilize generation a lot.

What I'm *hoping* for are chunks that are somewhat prebuilt and just placed about in a somewhat random fashion. (Anything too much more complicated might be too advanced for me to understand any time soon.)

This is such a big question that I'm debating creating a thread for it. But if anyone can help me figure out what is going on I would really really appreciate it. The more I know the better. (Like how does it know that the character is never 100% blocked from being able to complete the level???)



Title: Re: Game Maker Help Thread!
Post by: Moloch on June 12, 2013, 06:54:36 AM
Hi again everyone.

I have a big question.

How does Spelunky handle random generation?
I need to understand how it works because my game is going to need to utilize generation a lot.

What I'm *hoping* for are chunks that are somewhat prebuilt and just placed about in a somewhat random fashion. (Anything too much more complicated might be too advanced for me to understand any time soon.)

This is such a big question that I'm debating creating a thread for it. But if anyone can help me figure out what is going on I would really really appreciate it. The more I know the better. (Like how does it know that the character is never 100% blocked from being able to complete the level???)

Hi. All your questions have been answered.

http://tinysubversions.com/2009/09/spelunkys-procedural-space/
http://tinysubversions.com/2010/01/tutorial-modding-spelunkys-level-generator/
http://tinysubversions.com/2012/08/listen-to-me-babble-about-spelunkys-procedural-generation/
http://makegames.tumblr.com/post/4061040007/the-full-spelunky-on-spelunky
http://johnmikulablog.blogspot.ca/2013/02/the-spelunky-challenge.html


Title: Re: Game Maker Help Thread!
Post by: HaydenDavenport on June 12, 2013, 07:45:30 AM
Well that went much better than expected. Thank you! :D

Time to learn! :)


Title: Re: Game Maker Help Thread!
Post by: HaydenDavenport on June 13, 2013, 12:57:15 PM
Ok. I read through everything, and I feel confident in my understanding of how the level randomization works. But I still don't know how the game tests for whether or not a level is solvable. Is there anything written on that?


Title: Re: Game Maker Help Thread!
Post by: hyperme on June 13, 2013, 01:44:22 PM
Ok. I read through everything, and I feel confident in my understanding of how the level randomization works. But I still don't know how the game tests for whether or not a level is solvable. Is there anything written on that?

Cleverly. Some dice rolls involved, via rand(). Also remembering the previous location.

From what I've worked out from scrLevelGen():

0. Create a 4 by 4 array to represent the level path. Fill it with 0.
1. Pick a random X position on the top of the level for the entrance. The top is row 0. This is important later!
2. Set your 'location' to the entrance.
3. Pick a direction from left/right/down to move randomly.
4. If the position you want to move to has a 0, move into it and make it a 1.
5. Repeat 4 and 5. Eventually, you'll;
a) Decide to move down.
b) Hit the edge of the level, not be able to turn back because a 1 is behind you. So you have to go down.
6. When you move down, make the space you moved into a 3. Make the space you moved from a 2.
7. Repeat 4, 5 and 6 until you try to move into row 4.
8. Set the exit on row 3 where you tried to move down.
9. Do all the level gen stuff.

Now, since scrLevelGen() is lightly commented, some of this, name the level size, might be wrong. But I'm pretty sure most of it is right.

EDIT:
To track the room path number in Spelunky, add this to an execute code block in oPlayer1's draw event. It's educational.

Code:
if(isRealLevel())
{
draw_set_font(global.myFontSmall);
draw_set_color(c_blue);
draw_text(x,y, global.roomPath[scrGetRoomX(x), scrGetRoomY(y)]);
}


Title: Re: Game Maker Help Thread!
Post by: CaSoDaN on June 25, 2013, 01:03:56 PM
Help?!?!
(http://i.imgur.com/LI6s5U2.png)
Randomly happened when I tried to test my new mod.


Title: Re: Game Maker Help Thread!
Post by: Moloch on June 25, 2013, 02:15:21 PM
Help?!?!
(http://i.imgur.com/LI6s5U2.png)
Randomly happened when I tried to test my new mod.

The fate of your mod has been decided. It has no future.


Title: Re: Game Maker Help Thread!
Post by: CaSoDaN on June 25, 2013, 02:27:31 PM
Help?!?!
(http://i.imgur.com/LI6s5U2.png)
Randomly happened when I tried to test my new mod.

The fate of your mod has been decided. It has no future.
CAN'T BE!


Title: Re: Game Maker Help Thread!
Post by: Moloch on June 25, 2013, 02:32:53 PM
 :D
What version of Game Maker are you using? Did the game run before you added your modding changes? I've never seen that error so more info would help.


Title: Re: Game Maker Help Thread!
Post by: CaSoDaN on June 25, 2013, 02:36:34 PM
:D
What version of Game Maker are you using? Did the game run before you added your modding changes? I've never seen that error so more info would help.
I'm using 8.0, and I didn't test it before I added the new features. Also I was using the Editor Plus Fan Update source.


Title: Re: Game Maker Help Thread!
Post by: Moloch on June 25, 2013, 02:53:27 PM
I'm using 8.0, and I didn't test it before I added the new features. Also I was using the Editor Plus Fan Update source.

i'm still guessing, but here's a few ideas.
- make sure you have the files/folders that come with the original Spelunky .zip in the folder you are testing the source from (or running the .exe)... supersound.dll and the sound folder are needed for it to run at the very least
- test any other .gmk see if it runs


Title: Re: Game Maker Help Thread!
Post by: CaSoDaN on June 25, 2013, 03:04:38 PM
I tried all of those.


Title: Re: Game Maker Help Thread!
Post by: Moloch on June 25, 2013, 03:10:01 PM
Your screenshot looks like Windows 8. I have no experience running GM on Windows 8...maybe that has something to do with it...otherwise I'm out of guesses!


Title: Re: Game Maker Help Thread!
Post by: CaSoDaN on June 27, 2013, 05:27:30 PM
How would one go about adding custom music? I put this in the startMusic script:
if (isRoom("rSuper"))
    {
        if (oPlayer1.active)
        {
            playMusic(global.musSuper, true);
            SS_SetSoundVol(global.musSuper, 2000 + 8000 * (global.musicVol/18));
            SS_SetSoundFreq(global.musSuper, 44100);
        }
        }

I also added this to the oMusic code:
global.musSuper = SS_LoadSound("sound/boss2.ogg", 1);

EDIT: Moloch helped me fix it. Thanks Moloch!


Title: Re: Game Maker Help Thread!
Post by: hyperme on August 17, 2013, 03:05:50 PM
How do I perform the fancy many screen trickery the Title room has? When I try it, the game insists on setting the view position to (0,0). What do I change to stop that, so my view scrolling scrolls?


Title: Re: Game Maker Help Thread!
Post by: SuperX46 on October 25, 2013, 05:22:51 PM
How do you add new enemies? Do I just add programming to the enemy, set it's parent to oEnemy and it does it automatically? And how would I make it only spawn in a specific area? Would love help.


Title: Re: Game Maker Help Thread!
Post by: halibabica on October 25, 2013, 07:25:57 PM
It depends on what kind of enemy you want to make. If there's something similar already, you can duplicate the existing enemy and make whatever changes are needed. Having oEnemy as the parent is a good idea, but not always necessary. What enemies spawn in what locations is controlled by one of the level gen scripts. I can't remember which, but it should be easy to find.


Title: Re: Game Maker Help Thread!
Post by: ATP on January 01, 2014, 05:19:17 PM
I need to add saving and loading to custom levels. My first few attempts were simple game_save and game_load operations that worked fine until I restarted the game, at which point they caused it to crash when I loaded and tried to move between levels.

Does anyone have any ideas? I'm not sure how to approach this.


Title: Re: Game Maker Help Thread!
Post by: halibabica on January 01, 2014, 07:57:01 PM
Editor Plus and TLS have some basic auto-saving features already. You could probably expand off of those to something more flexible.


Title: Re: Game Maker Help Thread!
Post by: SnoruntPyro on February 06, 2014, 08:15:23 PM
I'm a sort-of-novice at Game Maker, so I have a few questions.

I'm adding Hell into the original, and I'm getting some problems with levels beyond Olmec:
(http://i.imgur.com/UAbGKcW.png)
The levels in Hell seem to have the abyss...any way to fix this?
(http://i.imgur.com/0ONS1BE.png)
How do I change transitions?
(http://i.imgur.com/zh9ZUYb.png)
When I die on any Hell level (17-20), this error pops up. I've looked into this and there's no line 517...

Also, where does Spelunky store its flavor text (e.g. I HEAR SNAKES...I HATE SNAKES!)? I want to change the city of gold message.

Thanks!


Title: Re: Game Maker Help Thread!
Post by: halibabica on February 07, 2014, 05:13:43 AM
I don't remember exactly where the script for generating bottomless pits is, but I'd check around the scripts that make the ice levels. It might be due to an equation with the level counter.

If I remember correctly, the game uses the same transition room for every transition, and just changes its appearance based on level count.

oPlayer1's step event has multiple pages, so make sure you check all of them for line 517. It also includes some scripts, but I think it would specify if the error was in one.

Lastly, the flavor text is in one of oPlayer1's alarms.


Title: Re: Game Maker Help Thread!
Post by: Whooper1222 on February 07, 2014, 07:00:19 AM
Flavor text? Really?


Title: Re: Game Maker Help Thread!
Post by: halibabica on February 07, 2014, 08:23:07 AM
Yes, really.


Title: Re: Game Maker Help Thread!
Post by: bloxxin on February 07, 2014, 03:55:59 PM
Isn't it called the 'Level Feeling'?


Title: Re: Game Maker Help Thread!
Post by: Moloch on February 07, 2014, 04:48:54 PM
The levels in Hell seem to have the abyss...any way to fix this?

How do I change transitions?

When I die on any Hell level (17-20), this error pops up. I've looked into this and there's no line 517...
1.
Figure out which room you want to generate your hell levels in...the only difference between them is how deep they are. The bottomless level for the ice caves uses room rLevel2. You probably want to generate hell levels using rLevel (normal sized mine/jungle/temple levels) or rLevel3 (an extra room deep for jungle lakes). Also look at how global.levelType is used in scrInitLevel for generating the level borders.

2.
There's 2 transition rooms for each area, the only difference is their appearance. Control which level gets loaded next and which room size is used with oTransition. Look at the 'Animation End' event for oPlayer1 too for how to change where exit doors lead to.

3.
The error messages are confusing to read, yeah! 'ERROR in action number 3' narrows it down. When you have the Step event in oPlayer1 properties selected, you'll see the list of Actions on the right, the third one is an 'execute a piece of code' block - that's where you want to look for line 517.
But to fix *that* error i think you need to look in scrReadStats and scrWriteStats and increase the size of the array from 16 to your new highest level number.


Title: Re: Game Maker Help Thread!
Post by: Whooper1222 on February 08, 2014, 01:57:37 AM
Isn't it called the 'Level Feeling'?
That's what I wanted to point out in my previous post.


Title: Re: Game Maker Help Thread!
Post by: halibabica on February 08, 2014, 05:05:14 AM
Flavor text is just a more general term.

Moloch is more helpful than me. I've been away from this too long. :-X


Title: Re: Game Maker Help Thread!
Post by: Moloch on February 08, 2014, 07:28:33 AM
Each level has its own flavor, but overall it Tastes Like Spelunky. Riiiiight?


Title: Re: Game Maker Help Thread!
Post by: SnoruntPyro on February 08, 2014, 04:11:07 PM
Thanks! The problems are fixed.

Next question: the music for Hell will not stop. It plays into the transitions, when I die, and continues into the title screen. I've added it to functions in oMusic, oScreen, stopAllMusic, startMusic, scrInit, and scrMusicFade, but it doesn't seem to stop. I temporarily switched the .ogg name out with the Jungle's and it still wouldn't stop, so it's not a problem with the .ogg.


Title: Re: Game Maker Help Thread!
Post by: Bae on February 10, 2014, 09:54:07 PM
as far as I know Spelunky's music code has been a mystery for years

that said if anyone knows how to add additional songs beyond the accepted 5 to editor levels that would be neat


Title: Re: Game Maker Help Thread!
Post by: TyrOvC on February 10, 2014, 10:33:09 PM
Thanks! The problems are fixed.

Next question: the music for Hell will not stop. It plays into the transitions, when I die, and continues into the title screen. I've added it to functions in oMusic, oScreen, stopAllMusic, startMusic, scrInit, and scrMusicFade, but it doesn't seem to stop. I temporarily switched the .ogg name out with the Jungle's and it still wouldn't stop, so it's not a problem with the .ogg.
If you properly added it to stopAllMusic it should stop on transitions at least.  Can you paste the code you added to oMusic to load it and the code where you start playing it?

as far as I know Spelunky's music code has been a mystery for years

that said if anyone knows how to add additional songs beyond the accepted 5 to editor levels that would be neat
Add
Code:
global.custom_level_music_cache=ds_map_create();
somewhere near the end of scrInit.

in the script startMusic delete:
Code:
    else
    {
        playMusic(global.musCave, true);
        SS_SetSoundVol(global.musCave, 2000 + 8000 * (global.musicVol/18));
        SS_SetSoundFreq(global.musCave, 44100);
    }
and insert:
Code:
    else if(oLoadLevel.music == "CAVE")
    {
        playMusic(global.musCave, true);
        SS_SetSoundVol(global.musCave, 2000 + 8000 * (global.musicVol/18));
        SS_SetSoundFreq(global.musCave, 44100);
    }
    else{
        if(oLoadLevel.music==""){
            exit;
        }
       
        if(ds_map_exists(global.custom_level_music_cache,oLoadLevel.music)){
            var musicSuperSoundID;
            musicSuperSoundID=ds_map_find_value(global.custom_level_music_cache, oLoadLevel.music);
            playMusic(musicSuperSoundID, true);
            SS_SetSoundVol(musicSuperSoundID, 2000 + 8000 * (global.musicVol/18));
            SS_SetSoundFreq(musicSuperSoundID, 44100);
        }else{
            var musicSuperSoundID;
            musicSuperSoundID=SS_LoadSound("levels/"+oLoadLevel.music, 1);
            ds_map_add(global.custom_level_music_cache, oLoadLevel.music, musicSuperSoundID);
            playMusic(musicSuperSoundID, true);
            SS_SetSoundVol(musicSuperSoundID, 2000 + 8000 * (global.musicVol/18));
            SS_SetSoundFreq(musicSuperSoundID, 44100);
        }
    }
in the same location.

Finally ad:
Code:
//Cycle through and stop any custom level music that's been loaded
var tempKey, i;
tempKey=ds_map_find_first(global.custom_level_music_cache);
for(i=0; i<ds_map_size(global.custom_level_music_cache); i+=1) {
    SS_StopSound(ds_map_find_value(global.custom_level_music_cache,tempKey));
    tempKey = ds_map_find_next(global.custom_level_music_cache, tempKey);
}
To the the script stopAllMusic.

With that, should be able to add any custom "somemusic.ogg" to the level folder, and in a custom level file change "CAVE" or whatever to "somemusic.ogg" to play the custom music.

This is a quick, incomplete (and untested) example though. Needs unloading of music and clearing of the ds_map after the player wins or quits a custom level.

Edit:
Also possibly needs error handling for if the sound file is missing? If I remember right Super Sound silently fails by default though, so not really needed.


Title: Re: Game Maker Help Thread!
Post by: Bae on February 10, 2014, 11:47:28 PM
that is so many letters oh my god

but thank you


Title: Re: Game Maker Help Thread!
Post by: SnoruntPyro on February 11, 2014, 06:03:06 AM
Here's the modified code:

in scrInit
Quote
SS_SetSoundVol(global.musTitle, 2000 + 8000 * (global.musicVol/18));
SS_SetSoundVol(global.musCave, 2000 + 8000 * (global.musicVol/18));
SS_SetSoundVol(global.musLush, 2000 + 8000 * (global.musicVol/18));
SS_SetSoundVol(global.musIce, 2000 + 8000 * (global.musicVol/18));
SS_SetSoundVol(global.musTemple, 2000 + 8000 * (global.musicVol/18));
SS_SetSoundVol(global.musBoss, 2000 + 8000 * (global.musicVol/18));
SS_SetSoundVol(global.musVictory, 2000 + 8000 * (global.musicVol/18));
SS_SetSoundVol(global.musCredits, 2000 + 8000 * (global.musicVol/18));
SS_SetSoundVol(global.musHell, 2000 + 8000 * (global.musicVol/18));

in stopAllMusic
Quote
SS_StopSound(global.musTitle);
SS_StopSound(global.musCave);
SS_StopSound(global.musLush);
SS_StopSound(global.musIce);
SS_StopSound(global.musTemple);
SS_StopSound(global.musHell);
SS_StopSound(global.musBoss);
SS_StopSound(global.musVictory);
SS_StopSound(global.musCredits);

in oMusic
Quote
global.musTitle = SS_LoadSound("sound/title.ogg", 1);
global.musCave = SS_LoadSound("sound/cave.ogg", 1);
global.musLush = SS_LoadSound("sound/lush.ogg", 1);
global.musIce = SS_LoadSound("sound/ice.ogg", 1);
global.musTemple = SS_LoadSound("sound/temple.ogg", 1);
global.musBoss = SS_LoadSound("sound/boss.ogg", 1);
global.musVictory = SS_LoadSound("sound/victory.ogg", 1);
global.musCredits = SS_LoadSound("sound/credits.ogg", 1);
global.musHell = SS_LoadSound("sound/hell.ogg", 1);
in startMusic
Quote
else if (oLoadLevel.music == "HELL")
    {
        playMusic(global.musHell, true);
        SS_SetSoundVol(global.musHell, 2000 + 8000 * (global.musicVol/18));
        SS_SetSoundFreq(global.musHell, 44100);
    }
Quote
else if (global.levelType == 5)
    {
        playMusic(global.musHell, true);
        SS_SetSoundVol(global.musHell, 2000 + 8000 * (global.musicVol/18));
        SS_SetSoundFreq(global.musHell, 44100);
    }

By the way, I get an error that says something along the lines of "error in function real()" attributed to oScreen, but I don't see anything. This happens outside of my mod. Probably happening because of the new hell.ogg file.


Title: Re: Game Maker Help Thread!
Post by: SnoruntPyro on February 11, 2014, 05:45:56 PM
By far the most confusing error message I've ever had.
Quote

___________________________________________
ERROR in
action number 1
of Create Event
for object oScreen:

Error in function real().
This probably has something to do with the music. There's no "real()" function anywhere.


Title: Re: Game Maker Help Thread!
Post by: TyrOvC on February 11, 2014, 06:19:47 PM
By far the most confusing error message I've ever had.
Quote

___________________________________________
ERROR in
action number 1
of Create Event
for object oScreen:

Error in function real().
This probably has something to do with the music. There's no "real()" function anywhere.
Actually I bet that has something to do with scrReadStats and your increased number of levels. It is pretty unhelpful though :P

Run the game in debug mode and see what the value of global.musHell is.
Edit: also in the debug mode there's a way to execute code, try running SS_StopSound(global.musHell); in it manually and see what happens


Title: Re: Game Maker Help Thread!
Post by: SnoruntPyro on February 11, 2014, 06:52:12 PM
scrReadStats looks fine:
Quote
for (i = 0; i < 20; i += 1)
{
    global.levelDeaths = 0;
}

for (i = 0; i < 27; i += 1)
{
    global.enemyDeaths = 0;
}

for (i = 0; i < 13; i += 1)
{
    global.miscDeaths = 0;
}

for (i = 0; i < 25; i += 1)
{
    global.enemyKills = 0;
}


musHell seems to be equal to 1 rather than 43255608. Also, your code didn't work. I'll check all of the supersound scripts.

BONUS: When coding...goes horribly wrong.
(http://i.imgur.com/ev9oQlT.png)

EDIT: I don't see anything in the supersound scripts.


Title: Re: Game Maker Help Thread!
Post by: Bae on February 11, 2014, 08:04:40 PM
99 bluecircle


Title: Re: Game Maker Help Thread!
Post by: bloxxin on February 11, 2014, 08:31:39 PM
99 bluecircle

It's obviously TLS's big sapphires, I mean blue donuts.


Title: Re: Game Maker Help Thread!
Post by: TyrOvC on February 11, 2014, 10:46:23 PM

musHell seems to be equal to 1 rather than 43255608. Also, your code didn't work. I'll check all of the supersound scripts.
Odd, should be some random high number that super sound assigns as the identity of the song. So somewhere between when the song is first played and when the stop music script is called, something changes global.musHell? Looks like a lead.


Edit:
That stuff I posted for Bae was only meant for custom levels, didn't mean for you to try that, sorry.


Title: Re: Game Maker Help Thread!
Post by: SnoruntPyro on February 12, 2014, 03:34:53 PM
I checked, and the music seems to work completely fine in the level editor.

EDIT: oh wow
The thing...that was causing the problem...was something that I put in the creation code script in all the rooms to try to correct the problem.

I...I...wow.


Title: Re: Game Maker Help Thread!
Post by: Moloch on February 13, 2014, 09:12:53 PM
Edit:
That stuff I posted for Bae was only meant for custom levels, didn't mean for you to try that, sorry.

FYI I also used that code for adding music to custom levels and it worked without problems. The only additional thing I had to do was copy the code to restart the music to the TLS/Editor Plus checkpoint loading script.


Title: Re: Game Maker Help Thread!
Post by: Shrek on March 29, 2014, 06:53:56 PM
What are the essentials of a room? I tried to make a new room but there's no HUD, the window's small, and the camera doesn't move. I feel like I'm missing a few objects as currently I only have four(oLevel, oGame, oPlayer1, and some ground).
What do I need to make the room function correctly? It's the 16th level, if that changes anything.
I'm not trying to make any random elements, I just want an empty room with walls and the player. Sorry if this question has been asked already.


Title: Re: Game Maker Help Thread!
Post by: bloxxin on March 29, 2014, 07:20:56 PM
@Shrek
~~Lack of HUD:
IDK, never experienced this problem, or forgot, sorry. I'll try to find it later though, but the lack of HUD may be because the window was to small.

~~Small Window:
There is an object called oScreen. Go to the last script in the create event and find the large-and-almost-identical block of code at the bottom. Copy one and paste it, changing one of the rooms with the proper room name of your empty room.

Here is an example. Change 'rLevel' into the name of your room.
Code:
room_set_view(rLevel,0,true,0,0,320,240,0,0,w,h,128,96,-1,-1,oPlayer1);

~~Camera Doesn't Move:
The problem is fixed by doing the above fix.


Title: Re: Game Maker Help Thread!
Post by: Shrek on March 29, 2014, 07:43:06 PM
Thank you for your quick reply, Bloxxin! oScreen probably should've been the first place for me to look :P
I still have to scavenge the code to get the HUD to show up, though. Also, I can't access my items through switching or through hotkeys. I remember a script somewhere called IsRealLevel() that could probably help...
Edit: IsRealLevel was just for stats.txt, but IsLevel made the HUD appear and even placed an invincible ceiling and walls!... I'll have to place invincible floors myself, but that shouldn't be too difficult.


Title: Re: Game Maker Help Thread!
Post by: bloxxin on March 29, 2014, 08:03:02 PM
That's good you found it yourself! I was looking at the scrDrawHUD code, saying it is called in the draw event of oGame, but it doesn't exist there.
The script name you mentioned made me look for the script isLevel, I found it and was about to mention it to you. before then you edited.


Title: Re: Game Maker Help Thread!
Post by: Hedwirez on June 19, 2014, 03:31:35 AM
I'm trying to reverse engineer the Spelunky source code to get an idea of how to build a platformer but am getting pretty stuck on the basics. I understand that the majority of the movement code is in the characterStepEvent but can't find the code that actually commits the movement (i.e. changes the x variable of the player). Can anyone point me in the right direction please?


Title: Re: Game Maker Help Thread!
Post by: Moloch on June 19, 2014, 04:34:43 AM
I'm trying to reverse engineer the Spelunky source code to get an idea of how to build a platformer but am getting pretty stuck on the basics. I understand that the majority of the movement code is in the characterStepEvent but can't find the code that actually commits the movement (i.e. changes the x variable of the player). Can anyone point me in the right direction please?

Near the bottom of characterStepEvent you'll see the moveTo script called.

Spelunky used this (http://martinpiecyk.com/site/platformengine/) platformer engine as a base. It's probably more complicated than it needs to be..I recommend reading old forum posts, blogs and tutorials by Matt Thorson, Kyle Pulver (xerus) and Chevy Ray for good platforming code ideas. You might have to dig a bit, since they have all since moved on from Game Maker. Here's a few links to get you started..

http://forums.tigsource.com/index.php?topic=5790.0
http://forums.tigsource.com/index.php?topic=3142.0
http://forums.tigsource.com/index.php?topic=7386


Title: Re: Game Maker Help Thread!
Post by: Hedwirez on June 22, 2014, 09:33:47 AM
Amazing, thanks. I now have a character that moves!