flyinian
Member
so, after several hours of trial and error. It appears that I got a system working.
It will randomly find a target and apply damage to it and update the grid with the new information.
i'm sure ill run into more problems.
If you see a problem with the code, please let me know.
Thank you.
It will randomly find a target and apply damage to it and update the grid with the new information.
i'm sure ill run into more problems.
If you see a problem with the code, please let me know.
Thank you.
GML:
var damage = 1;
var range = irandom_range(1,10); // max range would be grid height. havent implemented yet.
var target = ds_grid_get(enemy,1,range); // uses the range value to find a target from the grid's column.
if (target >= damage)
{
target -= 1; // apply damage to target
ds_grid_set(enemy,1,range,target); // update the value in the grid with new value.
}
else
{
// less health than damage
};
if (damage <= 0)
{
// if there is no more damage.
};
};
The original issue I had wasn't what I thought it was.
Here is my target selection and apply damage code.
The issue I have is that the grid value isn't being updated when changed.
The damage is still being applied but the new value is being discarded and not updating the grid position.
Here is my target selection and apply damage code.
The issue I have is that the grid value isn't being updated when changed.
The damage is still being applied but the new value is being discarded and not updating the grid position.
GML:
find = "no target";
show_debug_message("find: " + string(find));
var find = choose(enemy[# 1,1],enemy[# 1,2],enemy[# 1,3],enemy[# 1,4],enemy[# 1,5],enemy[# 1,6],enemy[# 1,7],enemy[# 1,8],enemy[# 1,9],enemy[# 1,10]);
show_debug_message("find: " + string(find));
show_debug_message("target health: " + string(find));
var damage = 1;
if (find >= damage)
{
// location that I am having the issue at.
find += damage; // This way doesn't work.
enemy[# 1,1] += 10; // this way works.
show_debug_message("target health after: " + string(find));
}
else
{
// less health than damage
};
if (damage <= 0)
{
// if there is no more damage.
}
;
I pulled data from a ds_grid and stored it into a ds_list so, I can shuffle and change the values stored in said list.
Now, since I am done shuffling and changing the values within the said list, I want to update the grid with the new data in the list.
How would I achieve this?
either code example or a source should do.
Thank you.
off topic question: could I avoid using a list and shuffle a specific column in a grid? I saw there is a function to shuffle the entire grid but, that's not what I want. Maybe define the height of a column to be shuffled and use irandom?
Now, since I am done shuffling and changing the values within the said list, I want to update the grid with the new data in the list.
How would I achieve this?
either code example or a source should do.
Thank you.
off topic question: could I avoid using a list and shuffle a specific column in a grid? I saw there is a function to shuffle the entire grid but, that's not what I want. Maybe define the height of a column to be shuffled and use irandom?
Last edited: