Hello everybody!
So I asked for help in the maker forums because I need to be able to identify potions by consuming them. The potions' effects are randomized each time you get in the dungeon. So you have 5 potions, 5 different effects, first time in the dungeon, the Red Potion heals you, second time in, Red Potion poisons you, etc. However, whenever you identified a Potion, it stays identified for the duration of the run, so every time you should be getting a Red Potion, you get a Healing Potion instead if it's what its been assigned to.
Everybody still with me? Good.
Now, I wrote some voodoo to help me initialize the whole boomshalala and get the potions assigned. It doesn't work, of course. I can't quite figure out how to ensure that each potion gets a different effect assigned. Then how to make it so that when it's consumed, it "transforms" into the Potion with the effect it should have.
Here's my gibberish:
Anyone got fifteen minutes and up for a small challenge? I really appreciate it!
So I asked for help in the maker forums because I need to be able to identify potions by consuming them. The potions' effects are randomized each time you get in the dungeon. So you have 5 potions, 5 different effects, first time in the dungeon, the Red Potion heals you, second time in, Red Potion poisons you, etc. However, whenever you identified a Potion, it stays identified for the duration of the run, so every time you should be getting a Red Potion, you get a Healing Potion instead if it's what its been assigned to.
Everybody still with me? Good.
Now, I wrote some voodoo to help me initialize the whole boomshalala and get the potions assigned. It doesn't work, of course. I can't quite figure out how to ensure that each potion gets a different effect assigned. Then how to make it so that when it's consumed, it "transforms" into the Potion with the effect it should have.
Here's my gibberish:
Code:
function PotionSetup() {
//this function gets a random value and you can set a deleteFlag in order to decide whether to remove that from the given array
var GetRandomElement = function(myArray) {
var randomItem = myArray[Math.floor(Math.random()*myArray.length)];
}
//Call PotionSetup() function in order to mix the potions.
var PotionMixer = function() {
var PotMix = new Array();
for (var i=1; i<5; ++i) {
PotMix.push(i);
}
$gameVariables.setValue(20, GetRandomElement(PotMix[1]));
$gameVariables.setValue(21, GetRandomElement(PotMix[2]));
$gameVariables.setValue(22, GetRandomElement(PotMix[3]));
$gameVariables.setValue(23, GetRandomElement(PotMix[4]));
$gameVariables.setValue(24, GetRandomElement(PotMix[5]));
}
}
Anyone got fifteen minutes and up for a small challenge? I really appreciate it!