B
Bladebss
Guest
so i have some code that adds xp to the enemy xp in a grid, one at a time, until it is equal to the xp to add. there is a for loop that runs on xp in that grid to see if the level up criteria is met and then adjusts the stats of the enemy in accordance with this. I have it this way so that if the enemy earns more than one levels worth of xp, it does the level up calculations the moment it reaches the required xp and then continues to add the xp, after the level up. the next levels xp is based of of the amount of xp the enemy had at the moment of level up, so it needs to be the right amount.
I tried it without this adding 1 xp at a time and it just looped to the end result before the level up criteria activated, the enemy only goes up one level and the amount needed for the next level is massive as its based off the total xp to add not the amount needed to level up.
so this adding 1 xp at a time works.. but its super slow.
the xp added is done at the beginning of a battle and the xp is to make the enemy the right level for that battle.
so at the beginning of the battle the enemy starts at level 1 and slowly raised up until they reach the correct level. but this seems really weird to the player as they watch the enemy slowly climb levels at the start of battle.
is there a way I can speed up the adding of 1 xp at a time or change the way its done, so that at the start of the battle the enemy appears at the right level from the beginning.
I did think I could just have the battle not start until the xp and the xp to add, are the same, but at higher levels this makes the time too long before the battle starts. honestly its madness!
"enemy_inventory,13,0" is the xp stat for the enemy
"global.enemyxp" is the amount of xp the enemy needs, to be the level required at the start of battle
"enemy_inventory,19,w" is level up, and is either true or false, based on if the conditions are met
"enemy_inventory,28,w" is the amount of xp the enemy needs to go up another level, and is doubled on level up being true
this is all in step event..
I tried it without this adding 1 xp at a time and it just looped to the end result before the level up criteria activated, the enemy only goes up one level and the amount needed for the next level is massive as its based off the total xp to add not the amount needed to level up.
so this adding 1 xp at a time works.. but its super slow.
the xp added is done at the beginning of a battle and the xp is to make the enemy the right level for that battle.
so at the beginning of the battle the enemy starts at level 1 and slowly raised up until they reach the correct level. but this seems really weird to the player as they watch the enemy slowly climb levels at the start of battle.
is there a way I can speed up the adding of 1 xp at a time or change the way its done, so that at the start of the battle the enemy appears at the right level from the beginning.
I did think I could just have the battle not start until the xp and the xp to add, are the same, but at higher levels this makes the time too long before the battle starts. honestly its madness!
"enemy_inventory,13,0" is the xp stat for the enemy
"global.enemyxp" is the amount of xp the enemy needs, to be the level required at the start of battle
"enemy_inventory,19,w" is level up, and is either true or false, based on if the conditions are met
"enemy_inventory,28,w" is the amount of xp the enemy needs to go up another level, and is doubled on level up being true
this is all in step event..
Code:
if(ds_grid_get(enemy_inventory,13,0)<global.enemyxp){ds_grid_set(enemy_inventory,13,0,ds_grid_get(enemy_inventory,13,0)+1);}}// if xp to add is more than enemy xp add 1 to it every step.
{
for(w=0; w< ds_grid_height(enemy_inventory);w++){
if (ds_grid_get(enemy_inventory,13,w) > ds_grid_get(enemy_inventory,28,w)) {ds_grid_set(enemy_inventory,19,w,true) ds_grid_set(enemy_inventory,11,w,ds_grid_get(enemy_inventory,11,w)+1)}}}//if the xp is greater than next level xp, level up is true, add one to level stat
if (ds_grid_get(enemy_inventory,19,0)=true){ds_grid_set (enemy_inventory,14,0,ds_grid_get(enemy_inventory,13,0) *2); // if level up is true, double the current xp and set next level stat
ds_grid_set (enemy_inventory,24,0,ds_grid_get(enemy_inventory,24,0) + (round(ds_grid_get(enemy_inventory,21,0)/ 3)));//increase attack by 3rd base attack
ds_grid_set (enemy_inventory,25,0,ds_grid_get(enemy_inventory,25,0) + (round(ds_grid_get(enemy_inventory,22,0)/3)));//increase defence by 3rd base defence
ds_grid_set (enemy_inventory,27,0,ds_grid_get(enemy_inventory,27,0) + (irandom_range(1,5))); // increase health by 1 to 5
ds_grid_set (enemy_inventory,28,0,ds_grid_get(enemy_inventory,14,0));// xp needed is double current xp
ds_grid_set(enemy_inventory,19,0,false);//level up is done
}