• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Storing a value to return to.(Solved)

S

Sam Brixey

Guest
Hello

I am planning on adding status effects to my game. The first effect i plan to add is Slow.

I intend to make this work by having characters have a status set to normal and when they are hit by an 'Orb of Slowness' for example then their status will change to slowed and this will run a script for slow (scr_status_slow) with arguments for strength of the slow and duration etc. I am thinking of having the slow effect be implemented by increasing the friction value of the object slowed ( i have not tested anything yet so not sure how well this work ) and I would like the objects friction value to set back to the original value once the script is set back to scr_status_normal ( for example ). How can i save the original value of friction to change back to? Or the original value of an objects speed if for example this is the route I ultimately end up taking? And also if no one minds is there an easier way to do this that i havn't thought of?

Apologies for the long post i am just trying to ensure the goal is properly explained.

Thanks :)
 
Z

zmads

Guest
This is the way I know how to do it, but probably there's better ways.
In the create event of the object you do something like this
Code:
normalspd = 10;
returnnormalspd= 10;
In the slow script you set your slow speed and create an alarm with the duration time like this
Code:
normalspd = 5;
alarm[0] = 120;
Inside this alarm you do this
Code:
normalspd = returnnormalspd
 
S

Sam Brixey

Guest
Reply to Matharoo

I'm not sure where I should store this variable. Should it be in the objects create event and have the scr_status_normal then set the friction to that value.

So for example;

obj_goblin

Create Event;
Var Goblinfriction = (whatever the friction value is)

Then in the Slow script;

friction = friction*10

And then in the Status_normal script;
friction = Goblinfriction
 
S

Sam Brixey

Guest
Zmads

Thanks that seems to reinforce Matharoos post. I have a way foward :)

Thanks a lot for the help
 

matharoo

manualman
GameMaker Dev.
You don't need to write "Reply to <name>" in your reply every time, you can use the Reply button at the bottom-right of someone's post to reply to that post/person.
 

sylvain_l

Member
friction can do what you want, but perhaps not as you wish(IMHO).
friction more define the "force" which will slow down your object. If friction = 0, your object keep is speed constant. if friction >0 it slow down, the slow down being faster as friction is greater.
Also note that friction IS constant (a fixed amount substracted to speed at every step)

How do you currently set your speed /acceleration ? Will it work fine with friction ?
if you just set the speed=20 when player press left, adding more friction, won't change the fact that player move at speed=20 as long as left is pressed. (it will just slow down faster when it stop being pressed)
 
S

Sam Brixey

Guest
You don't need to write "Reply to <name>" in your reply every time, you can use the Reply button at the bottom-right of someone's post to reply to that post/person.
Thanks for the info :)
 
S

Sam Brixey

Guest
friction can do what you want, but perhaps not as you wish(IMHO).
friction more define the "force" which will slow down your object. If friction = 0, your object keep is speed constant. if friction >0 it slow down, the slow down being faster as friction is greater.
Also note that friction IS constant (a fixed amount substracted to speed at every step)

How do you currently set your speed /acceleration ? Will it work fine with friction ?
if you just set the speed=20 when player press left, adding more friction, won't change the fact that player move at speed=20 as long as left is pressed. (it will just slow down faster when it stop being pressed)
I have just realised this whilst trying to add this to my game. I am now just trying to change the objects speed and then return this value to the original once the slow duration ends but I am having issues with this as well. I'm not sure exactly why though but I am trying out various new things such as script arguments as well so the problem could be anything at this point. :p
 
S

Sam Brixey

Guest
Just an update,

I have managed to get my slow effect to work by changing the objects speed in the slow script and back to the original using a variable set in the objects create event using a normal state script.

Only issue I was having at this point is that I was not executing the script in the step event. Always learning :)

Thanks again for the help all
 
Top