TheName'sDash
Member
Hello! I'm not always the best at wording things, so I apologize if this gets confusing.
I've been reworking the battle system for my turn-based RPG, so that I can easily change the stats and appearance of different types of enemies. The way I've been trying to implement this is by storing all the enemies' stats and such in different arrays, all of which are stored in a script called "scr_enemystats". The enemy object already has an array with the default enemy stats. (For reference, the array is simply called "enemystats".)
I only had one regular enemy fully implemented in the old system, so I've been trying to implement its stats to the new one. The array containing its stats is called "badapplestats", and it reads as follows:
And again, for reference, here's the array with the default stats that are loaded unless the enemy's type is specified in the creation code:
Now, all I want to do is set the values in "enemystats" to be equal to the values in "badapplestats". I have tried a few different methods to make this work. At first, I tried the most simple thing I could think of, not really expecting it to work-- I simply wrote:
And, well, that obviously didn't work. I then read the manual, and found the "array_copy" page. I then more-or-less copied what was on there:
Aaaaand, that didn't work either, despite the description on the page stating "The above code will check two arrays to see if they hold equivalent values, and if they do not then the code will copy the entire contents of the array 'inventory_array' to the array 'item_array'. "
I tried a few different variations of that code as well, changing a few things around, stored different parts of it in local variables, in hopes that it would help.
... It did not.
When I run the game, the top of the screen, where the name is supposed to be displayed, still just says "Enemy". The HP is set to 1. The info box shows the default messages. Ahhhh.
Also, in case anyone's wondering, yes, the script containing the badapplestats array is called at the top of the create event, and yes, "enemytype" is set to "badapple" in the object's creation code in the test room. I've checked for typos-- I even copy/pasted variable names and such to make sure of that-- but I've come up with nada.
So, what am I doing wrong? Am I completely misunderstanding the limitations of arrays? Are there any obvious errors from the code-snippets? Is my implementation just poor? Does this have to do with the way scripts have been changed in GMS 2.3?
Thank you for your time, I hope I made myself understood, and I apologize once more in case I'm just being stupid. (I don't know all the ins-and-outs of GML, so maybe this just isn't possible. : P)
I've been reworking the battle system for my turn-based RPG, so that I can easily change the stats and appearance of different types of enemies. The way I've been trying to implement this is by storing all the enemies' stats and such in different arrays, all of which are stored in a script called "scr_enemystats". The enemy object already has an array with the default enemy stats. (For reference, the array is simply called "enemystats".)
I only had one regular enemy fully implemented in the old system, so I've been trying to implement its stats to the new one. The array containing its stats is called "badapplestats", and it reads as follows:
Code:
//Name
badapplestats[0] = "Bad Apple";
//HP
badapplestats[1] = 200;
//Attack
badapplestats[2] = 5;
//Speed
badapplestats[3] = 1;
//Info page 1
//(Use [0])
//Info page 2
badapplestats[4] = "You've never been a fan of apples...";
//Info page 3
badapplestats[5] = "120BPM, 4/4 time signature";
//Timeline for counter-riff
badapplestats[6] = tim_appleroll;
//Sprite
badapplestats[7] = spr_badapple;
//Background
badapplestats[8] = spr_battlebg1;
//Backing track
badapplestats[9] = snd_badapplebacking;
//Lead track
badapplestats[10] = snd_badapplelead;
Code:
//Name
enemystats[0] = "Enemy";
//HP
enemystats[1] = 1;
//Attack
enemystats[2] = 1;
//Speed
enemystats[3] = 1;
//Info page 1
//(Use [0])
//Info page 2
enemystats[4] = "Flavour text";
//Info page 3
enemystats[5] = "xBPM, y/y time signature";
//Timeline for counter-riff
enemystats[6] = tim_appleroll;
//Sprite
enemystats[7] = sprite_index;
//Background
enemystats[8] = spr_battlebg1;
//Backing track
enemystats[9] = snd_badapplebacking;
//Lead track
enemystats[10] = snd_badapplelead;
Code:
if enemytype = "badapple"{
enemystats = badapplestats;
}
Code:
if enemytype = "badapple"{
if !array_equals(badapplestats, enemystats)
{
var _len = array_length_1d(badapplestats);
array_copy(enemystats, 0, badapplestats, 0, _len);
}
}
I tried a few different variations of that code as well, changing a few things around, stored different parts of it in local variables, in hopes that it would help.
... It did not.
When I run the game, the top of the screen, where the name is supposed to be displayed, still just says "Enemy". The HP is set to 1. The info box shows the default messages. Ahhhh.
Also, in case anyone's wondering, yes, the script containing the badapplestats array is called at the top of the create event, and yes, "enemytype" is set to "badapple" in the object's creation code in the test room. I've checked for typos-- I even copy/pasted variable names and such to make sure of that-- but I've come up with nada.
So, what am I doing wrong? Am I completely misunderstanding the limitations of arrays? Are there any obvious errors from the code-snippets? Is my implementation just poor? Does this have to do with the way scripts have been changed in GMS 2.3?
Thank you for your time, I hope I made myself understood, and I apologize once more in case I'm just being stupid. (I don't know all the ins-and-outs of GML, so maybe this just isn't possible. : P)