GameMaker (Question) Stat Gain

I'm making a battle system similar to Final Fantasies. At the end of the battle, I want it to display what you gained from the battle. For example. Let's say I have 20 gold I win a battle I want it to show how much gold I gained in a draw GUI event that would look similar to this. (Better Example)

Essence: 25 +6
Cash: 40 +4

Code:
 //Enemy Step Event if objCallList.turn = false
{
    objCallList.hp -= 1;
    objCallList.turn = true;
}

if objCallList.ehp == 0 && scanned = 0
{
    instance_create_layer(500,380,"Instances",objStatGain)
    objCallList.money += moneyGain;
    objCallList.xp += xpGain;
    scanned = 1;
}

//Stat Gain Draw GUI
if moneyIncreased = true
{
    draw_text(x,y,"Money: " + string(objCallList.moneyBefore) + " +" + string(objChocoBattle0.moneyGain))
    show_debug_message("Printed!")
}
I'm not sure how to store a number and then use it later to show what the player has gained. Any idea or examples on how to do this would be greatly appreciated!
 
A

Alex_Beach

Guest
I would throw those variables into the stat object when it's created. Just create 2 variables in the objStatGain object moneyBeore and moneyGain. Then use "with" to adjust those values on object creation.
Code:
 with(instance_create_layer(500,380,"Instances",objStatGain))
{
moneyBefore=objCalllist.money; //set this variable to your current money
moneyGain=other.moneyGain;//set this variable to the amount that will be added to the money
}
Then, when you draw_text, just toss those variables into your draw GUI
Code:
 draw_text(x,y,"Money: " + string(moneyBefore) + " +" + string(moneyGain))
 
You can create a few variables (or an array, if necessary) named "VALUE_original", etc.
At the beginning of your fight sequence, store all your variables into those initial values to use later.
Then at the end, find the difference via subtraction, ie:
Code:
(VALUE - VALUE_original)
to determine the amount each variable was changed by.
 
I would throw those variables into the stat object when it's created. Just create 2 variables in the objStatGain object moneyBeore and moneyGain. Then use "with" to adjust those values on object creation.
Code:
 with(instance_create_layer(500,380,"Instances",objStatGain))
{
moneyBefore=objCalllist.money; //set this variable to your current money
moneyGain=other.moneyGain;//set this variable to the amount that will be added to the money
}
Then, when you draw_text, just toss those variables into your draw GUI
Code:
 draw_text(x,y,"Money: " + string(moneyBefore) + " +" + string(moneyGain))
I should have mentioned that moneyGain is a random range. When I tried this method the game softlocked on the menu.


You can create a few variables (or an array, if necessary) named "VALUE_original", etc.
At the beginning of your fight sequence, store all your variables into those initial values to use later.
Then at the end, find the difference via subtraction, ie:
Code:
(VALUE - VALUE_original)
to determine the amount each variable was changed by.

Trying this now.
 
You can create a few variables (or an array, if necessary) named "VALUE_original", etc.
At the beginning of your fight sequence, store all your variables into those initial values to use later.
Then at the end, find the difference via subtraction, ie:
Code:
(VALUE - VALUE_original)
to determine the amount each variable was changed by.

This worked thanks so much!
 
Top