<!--This Document is generated by GameMaker, if you edit it by hand then you do so at your own risk!-->
<object>
  <spriteName>&lt;undefined&gt;</spriteName>
  <solid>0</solid>
  <visible>-1</visible>
  <depth>0</depth>
  <persistent>0</persistent>
  <parentName>&lt;undefined&gt;</parentName>
  <maskName>&lt;undefined&gt;</maskName>
  <events>
    <event eventtype="0" enumb="0">
      <action>
        <libid>1</libid>
        <id>603</id>
        <kind>7</kind>
        <userelative>0</userelative>
        <isquestion>0</isquestion>
        <useapplyto>-1</useapplyto>
        <exetype>2</exetype>
        <functionname></functionname>
        <codestring></codestring>
        <whoName>self</whoName>
        <relative>0</relative>
        <isnot>0</isnot>
        <arguments>
          <argument>
            <kind>1</kind>
            <string>turn_order = 0
</string>
          </argument>
        </arguments>
      </action>
    </event>
    <event eventtype="2" enumb="1">
      <action>
        <libid>1</libid>
        <id>603</id>
        <kind>7</kind>
        <userelative>0</userelative>
        <isquestion>0</isquestion>
        <useapplyto>-1</useapplyto>
        <exetype>2</exetype>
        <functionname></functionname>
        <codestring></codestring>
        <whoName>self</whoName>
        <relative>0</relative>
        <isnot>0</isnot>
        <arguments>
          <argument>
            <kind>1</kind>
            <string>///Giving everyone their turns
//Player actions are at the very end of objStatusMaster.
if instance_exists(objBattleKiller) {
    alarm[1] = 1
} else {
    var next_turn;
    next_turn = ds_priority_delete_max(turn_order); 
    switch next_turn {
        case "player1":
            if !global.dead[1] {
                with instance_create(0,0,objStatusMaster) { pl = 1; }
            } else {
                event_perform(ev_other,ev_user0)
            }
            break;
        case "player2":
            if !global.dead[2] {
                with instance_create(0,0,objStatusMaster) { pl = 2; }
            } else {
                event_perform(ev_other,ev_user0)
            }
            break;
        case "player3":
            if !global.dead[3] {
                with instance_create(0,0,objStatusMaster) { pl = 3; }
            } else {
                event_perform(ev_other,ev_user0)
            }
            break;
        case "player4":
            if !global.dead[4] {
                with instance_create(0,0,objStatusMaster) { pl = 4; }
            } else {
                event_perform(ev_other,ev_user0)
            }
            break;
        case "enemy1":
            if global.enemy[1] != 0 {
                instance_create(0,0,objEnStatusMaster)
                enmy = 1
            } else {
                event_perform(ev_other,ev_user0)
            }
            break;
        case "enemy2":
            if global.enemy[2] != 0 {
                instance_create(0,0,objEnStatusMaster)
                enmy = 2
            } else {
                event_perform(ev_other,ev_user0)
            }
            break;
        case "enemy3":
            if global.enemy[3] != 0 {
                instance_create(0,0,objEnStatusMaster)
                enmy = 3
            } else {
                event_perform(ev_other,ev_user0)
            }
            break;
        case "enemy4":
            if global.enemy[4] != 0 {
                instance_create(0,0,objEnStatusMaster)
                enmy = 4
            } else {
                event_perform(ev_other,ev_user0)
            }
            break;
        case "enemy5":
            if global.enemy[5] != 0 {
                instance_create(0,0,objEnStatusMaster)
                enmy = 5
            } else {
                event_perform(ev_other,ev_user0)
            }
            break;
        case "npc":
            with objInBattleNPC { event_perform(ev_other,ev_user0); } 
            break;
        default:
            event_perform(ev_other,ev_user0)
            break;
    }
}
</string>
          </argument>
        </arguments>
      </action>
    </event>
    <event eventtype="7" enumb="12">
      <action>
        <libid>1</libid>
        <id>603</id>
        <kind>7</kind>
        <userelative>0</userelative>
        <isquestion>0</isquestion>
        <useapplyto>-1</useapplyto>
        <exetype>2</exetype>
        <functionname></functionname>
        <codestring></codestring>
        <whoName>self</whoName>
        <relative>0</relative>
        <isnot>0</isnot>
        <arguments>
          <argument>
            <kind>1</kind>
            <string>///First turn
turn_master()
for (var i=1;i&lt;global.pl_count+1;i++) {
    global.healthbar[i].y = global.healthbar[i].ystart
}

objBattleController.number_of_turns++
with instance_create(0,0,objBattleKiller) { first_turn = 1 }
</string>
          </argument>
        </arguments>
      </action>
    </event>
    <event eventtype="7" enumb="11">
      <action>
        <libid>1</libid>
        <id>603</id>
        <kind>7</kind>
        <userelative>0</userelative>
        <isquestion>0</isquestion>
        <useapplyto>-1</useapplyto>
        <exetype>2</exetype>
        <functionname></functionname>
        <codestring></codestring>
        <whoName>self</whoName>
        <relative>0</relative>
        <isnot>0</isnot>
        <arguments>
          <argument>
            <kind>1</kind>
            <string>/// What should I do when a turn ends?
turn ++
global.custom_msg = 0
if !ds_priority_empty(turn_order) {
    write_line("Turn "+string(turn-1)+" ended")
    alarm[1] = 1
} else {
    // What should I do when all turns end?
    write_line("All turns ended")
    write_line("---------------")
    global.battle_type = 0;
    global.remove_pp[1] = 0;
    global.remove_pp[2] = 0;
    global.remove_pp[3] = 0;
    global.remove_pp[4] = 0;
    ds_priority_destroy(turn_order);
    //ds_list_shuffle(turn_order);
    turn = 0;
    with objBattleController { event_perform(ev_other,ev_user0) }
}
</string>
          </argument>
        </arguments>
      </action>
    </event>
    <event eventtype="7" enumb="10">
      <action>
        <libid>1</libid>
        <id>603</id>
        <kind>7</kind>
        <userelative>0</userelative>
        <isquestion>0</isquestion>
        <useapplyto>-1</useapplyto>
        <exetype>2</exetype>
        <functionname></functionname>
        <codestring></codestring>
        <whoName>self</whoName>
        <relative>0</relative>
        <isnot>0</isnot>
        <arguments>
          <argument>
            <kind>1</kind>
            <string>///Create battle killer
for (var i=1;i&lt;global.pl_count+1;i++) {
    with global.healthbar[i] {
        y = ystart
    }
}
instance_create(0,0,objBattleKiller)
</string>
          </argument>
        </arguments>
      </action>
    </event>
    <event eventtype="7" enumb="5">
      <action>
        <libid>1</libid>
        <id>603</id>
        <kind>7</kind>
        <userelative>0</userelative>
        <isquestion>0</isquestion>
        <useapplyto>-1</useapplyto>
        <exetype>2</exetype>
        <functionname></functionname>
        <codestring></codestring>
        <whoName>self</whoName>
        <relative>0</relative>
        <isnot>0</isnot>
        <arguments>
          <argument>
            <kind>1</kind>
            <string>///Destroy turn list
if instance_exists(objBattleController) {
    if ds_exists(turn_order,ds_type_priority) {
        ds_priority_destroy(turn_order) 
    }
}
</string>
          </argument>
        </arguments>
      </action>
    </event>
  </events>
  <PhysicsObject>0</PhysicsObject>
  <PhysicsObjectSensor>0</PhysicsObjectSensor>
  <PhysicsObjectShape>0</PhysicsObjectShape>
  <PhysicsObjectDensity>0.5</PhysicsObjectDensity>
  <PhysicsObjectRestitution>0.100000001490116</PhysicsObjectRestitution>
  <PhysicsObjectGroup>0</PhysicsObjectGroup>
  <PhysicsObjectLinearDamping>0.100000001490116</PhysicsObjectLinearDamping>
  <PhysicsObjectAngularDamping>0.100000001490116</PhysicsObjectAngularDamping>
  <PhysicsObjectFriction>0.200000002980232</PhysicsObjectFriction>
  <PhysicsObjectAwake>-1</PhysicsObjectAwake>
  <PhysicsObjectKinematic>0</PhysicsObjectKinematic>
  <PhysicsShapePoints/>
</object>
