L
LanderMiskolczi
Guest
So I am trying to make this combat system, where the order, of who goes first, and last are up to how fast the characters Attack Speed is. So right as I have it, the order is random, but what I want is to have the fastest character go first.
Here is the code for the player:
Here is the enemy code:
Lastly, here is the object which I use to create the battle system
If you need anything to help, just ask please.
Hopefully you can see something I can't
Here is the code for the player:
Code:
Create Event:
execute code:
/// Varabiles
hspd = 0;
vspd = 0;
spd = 6;
fric = 1;
// Health
hp = 10;
maxHp = hp;
// Magic
mp = 5;
maxMp = mp;
// Attack
attackSpeed = 3;
attackStrength = 10;
// Armor
physicalArmor = 10;
magicalArmor = 5;
state = sc_movement_state;
Step Event:
execute code:
/// State
script_execute(state);
if (state == sc_your_turn)
{
if (x != 160)
{
x += 8;
}
}
Code:
Create Event:
execute code:
/// Varabiles
// Health
hp = 5;
maxHp = hp;
// Magic
mp = 0;
maxMp = mp;
// Attack
attackSpeed = 1;
attackStrength = 1;
// Armor
physicalArmor = 0;
magicalArmor = 0;
state = sc_static_state;
Step Event:
execute code:
/// State
if (state = sc_your_turn)
{
if (x != 320)
{
x -= 8;
}
}
Draw Event:
execute code:
/// Draw text
draw_self();
draw_text(x, y-32, hp);
draw_text(x+12, y-32, mp);
draw_text(x+24, y-32, attackSpeed);
draw_text(x+36, y-32, attackStrength);
draw_text(x+48, y-32, physicalArmor);
draw_text(x+60, y-32, physicalArmor);
Code:
Create Event:
execute code:
/// Varabiles
randomize();
field_type = 0;
execute code:
/// Field Create
speedList = ds_list_create();
// Allies
battleField[0] = instance_create(96, 160, ob_player);
battleField[1] = instance_create(96, 224, ob_ally);
battleField[0].state = sc_static_state;
ds_list_add(speedList, battleField[0].attackSpeed);
ds_list_add(speedList, battleField[1].attackSpeed);
// Enemy
sc_list_of_enemys();
var enemyNumber = irandom_range(1, 4);
var enemyType = field_type;
for (i = 0; i < enemyNumber; i++)
{
var battleNumber = i+2;
battleField[battleNumber] = instance_create(384, 96+(64*i), enemyId[enemyType, irandom_range(0, array_length_2d(enemyId, enemyType)-1)]);
ds_list_add(speedList, battleField[battleNumber].attackSpeed);
}
execute code:
/// Decide order of Battle
// Getting the speed Array
battleFieldLength = array_length_1d(battleField)-1;
ds_list_sort(speedList, true);
for (i = 0; i < battleFieldLength; i++)
{
speedArray[i] = speedList[| i];
}
ds_list_destroy(speedList);
// Setting Battle Order
for (i = 0; i < battleFieldLength; i++)
{
for (ii = 0; ii < battleFieldLength; ii++)
{
if (speedArray[i] == battleField[ii].attackSpeed)
{
battleOrder[i] = battleField[ii];
}
}
}
battleOrder[0].state = sc_your_turn;
Hopefully you can see something I can't