<!--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>0</visible>
  <depth>0</depth>
  <persistent>-1</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>network_set_config(network_config_connect_timeout, 5000);
strict_init("dictionary.json");
canSend = false;
connected = false;
queenHealthWait = false;
queenDead = false;
seedSent = false;
seedReceived = false;
var type;
type = network_socket_tcp;
var file = file_text_open_read(working_directory + "\ipaddress.txt");
ipaddress = file_text_read_string(file);
file_text_close(file);
port = 64198;
socket = network_create_socket(type);
isConnected = network_connect(socket, ipaddress, port);

var size, type, alignment;
size = 1024;
type = buffer_grow;
alignment = 1;
buffer = buffer_create(size, type, alignment);

global.queenhealthPrev = 600;
global.queenphasePrev = 0;

global.clientID = 0;
global.packetID = 0;
global.receivedPacketID = 0;
global.onlineList = ds_grid_create(3, 35);
global.onlineSend = ds_grid_create(3, 35);
global.onlineReceived = ds_grid_create(3, 35);
global.storedBuffers = ds_grid_create(2, 1);
global.receivedPacketIDs = ds_list_create();
ds_grid_clear(global.onlineSend, -1);
ds_grid_clear(global.onlineReceived, -1);
for(var i=0; i&lt;ds_grid_height(global.onlineList); i++){
    ds_grid_set(global.onlineList, 2, i, i);
}

update_variables("initprev");

update_variables("onlinevars");
</string>
          </argument>
        </arguments>
      </action>
    </event>
    <event eventtype="1" 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>network_destroy(socket);
buffer_delete(buffer);
ds_grid_destroy(global.onlineList);
ds_grid_destroy(global.onlineSend);
ds_grid_destroy(global.onlineReceived);
ds_grid_destroy(global.storedBuffers);
ds_list_destroy(global.receivedPacketIDs);
if(connected){
    popup_text("Disconnected");
}
</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>if(queenHealthResetQueued){
    if(!is_undefined(oQueenHead.myhealth) &amp;&amp; !is_undefined(oQueen.phase)){
        oQueenHead.myhealth = queenHealth;
        oQueen.phase = phase;
        if(state == 100){
            oQueen.state = state;
            oQueen.statetime = 0;
        }
        queenHealthResetQueued = false;
    }
    alarm[1] = 5;
}
</string>
          </argument>
        </arguments>
      </action>
    </event>
    <event eventtype="2" 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>
update_variables("onlinevars");

for(var i=0; i&lt;ds_grid_height(global.onlineList); i++){
    if(global.onlineList[# 0, i] != global.onlineList[# 1, i] &amp;&amp; i != 0 &amp;&amp; i != 1 &amp;&amp; i != 3){
        global.onlineSend[# 0, i] = global.onlineList[# 0, i];
        global.onlineSend[# 1, i] = global.onlineList[# 1, i];
        global.onlineSend[# 2, i] = global.onlineList[# 2, i];
        show_debug_message(string(global.onlineSend[# 0, i]) + " " + string(global.onlineSend[# 1, i]) + " " + string(global.onlineSend[# 2, i]));
        canSend = true;
        alarm[0] = 600;
    }

    if(i == 0){
        var v = 0;
        var itemPrev = global.onlineList[# 0, 0];
        var item = global.onlineList[# 1, 0];
        for(var f=0; f&lt;array_length_1d(item); f++){
            if(itemPrev[f] != item[f]){
                global.itemChanges[v, 0] = global.item[f];
                global.itemChanges[v, 1] = f;
                global.onlineSend[# 1, 0] = global.itemChanges;
                global.onlineSend[# 2, 0] = global.onlineList[# 2, 0];
                show_debug_message(string(global.itemPrev[f]) + " " + string(global.item[f]));
                show_debug_message("item changed");
                canSend = true;
                v++;
                
            }
        }
    }
    
    if(i == 1){
        var v = 0;
        var metdeadPrev = global.onlineList[# 0, 1];
        var metdead = global.onlineList[# 1, 1];
        for(var f=0; f&lt;array_length_1d(metdead); f++){
            if(metdeadPrev[f] != metdead[f]){
                global.metdeadChanges[v, 0] = global.metdead[f];
                global.metdeadChanges[v, 1] = f;
                global.onlineSend[# 1, 1] = global.metdeadChanges;
                global.onlineSend[# 2, 1] = global.onlineList[# 2, 1];
                show_debug_message(string(global.metdeadPrev[f]) + " " + string(global.metdead[f]));
                show_debug_message("metdead changed");
                canSend = true;
                v++;
                
            }
        }
    }
    
    if(i == 3){
        var v = 0;
        var eventPrev = global.onlineList[# 0, 3];
        var event = global.onlineList[# 1, 3];
        for(var f=0; f&lt;array_length_1d(eventPrev) - 1; f++){
            if(eventPrev[f] != event[f]){
                global.eventChanges[v, 0] = global.event[f];
                global.eventChanges[v, 1] = f;
                global.onlineSend[# 1, 3] = global.eventChanges;
                global.onlineSend[# 2, 3] = global.onlineList[# 2, 3];
                show_debug_message(string(global.eventPrev[f]) + " " + string(global.event[f]));
                show_debug_message("event changed");
                canSend = true;
                v++;
                
            }
        }
    }
}

if(canSend){
    buffer_delete(buffer);
    var size, type, alignment;
    size = 1024;
    type = buffer_grow;
    alignment = 1;
    buffer = buffer_create(size, type, alignment);
    buffer_seek(buffer, buffer_seek_start, 0);
    buffer_write(buffer, buffer_u8, 0);
    buffer_write(buffer, buffer_string, strict_compress(ds_grid_write(global.onlineSend)));
    buffer_write(buffer, buffer_u8, global.clientID);
    buffer_write(buffer, buffer_u32, global.packetID);
    global.storedBuffers[# 0, global.packetID] = global.onlineSend;
    global.storedBuffers[# 1, global.packetID] = global.clientID;
    var result = network_send_packet(socket, buffer, buffer_tell(buffer));
    show_debug_message("packetID = " + string(global.packetID));
    global.packetID++;
    ds_grid_resize(global.storedBuffers, 2, global.packetID + 1); 
    ds_grid_clear(global.onlineSend, -1);
}

if(!canSend){
    alarm[0] = 30;
}

if(canSend){
    canSend = false;
    alarm[0] = 75;
}

check_areaclear();

if(global.playerhealth &lt;= 0){
    if(oCharacter.state != oCharacter.DEFEATED){
        oCharacter.alarm[0] = 6;
        oCharacter.state = oCharacter.DEFEATED;
    }
}

if(!is_undefined(oQueenHead.myhealth) &amp;&amp; !is_undefined(oQueen.phase)){
    if(global.queenhealthPrev != oQueenHead.myhealth){
        show_debug_message("queen health sent " + string(oQueenHead.myhealth));
        var size, type, alignment;
        size = 1024;
        type = buffer_grow;
        alignment = 1;
        buffer = buffer_create(size, type, alignment);
        buffer_seek(buffer, buffer_seek_start, 0);
        buffer_write(buffer, buffer_u8, 2);
        buffer_write(buffer, buffer_s16, oQueenHead.myhealth);
        buffer_write(buffer, buffer_u8, global.clientID);
        buffer_write(buffer, buffer_s8, oQueen.phase);
        buffer_write(buffer, buffer_s8, oQueen.state);
        var result = network_send_packet(socket, buffer, buffer_tell(buffer));
    }
}
</string>
          </argument>
        </arguments>
      </action>
    </event>
    <event eventtype="3" 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>if(!connected){
    if(isConnected &gt;= 0){
        connected = true;
        popup_text("Connected");
        buffer_delete(buffer);
        var size, type, alignment;
        size = 1024;
        type = buffer_grow;
        alignment = 1;
        buffer = buffer_create(size, type, alignment);
        buffer_seek(buffer, buffer_seek_start, 0);
        buffer_write(buffer, buffer_u8, 1);
        var result = network_send_packet(socket, buffer, buffer_tell(buffer));
        alarm[0] = 5;
    } else {
        instance_destroy();
        popup_text("Failed to connect");
    }
}

if(!is_undefined(oQueen.phase)){
    if(oQueen.phase &gt;= 1 &amp;&amp; instance_exists(inst_146524)){
        event_perform_object(oQueenFireball, ev_other, ev_user1);
    }
    if(oQueen.phase &gt;= 2 &amp;&amp; instance_exists(inst_146525) &amp;&amp; instance_exists(inst_146520)){
        event_perform_object(oQueenFireball, ev_other, ev_user2);
    }
    if(oQueen.phase &gt;= 3 &amp;&amp; instance_exists(inst_146526) &amp;&amp; instance_exists(inst_146514)){
        event_perform_object(oQueenFireball, ev_other, ev_user3);
    }
    if((oQueen.phase &gt;= 4 || oQueen.phase == 5) &amp;&amp; instance_exists(inst_146527)){
        event_perform_object(oQueenFireball, ev_other, ev_user4);
    }
    if(global.event[303] &gt; 0 &amp;&amp; !queenDead){
        with(oQueen){
            height_target_front = 10;
            height_target_back = 10;
            head_obj.push = 0;
            head_obj.canhit = 0;
            head_obj.state = 100;
            head_obj.statetime = 0;
            leg1f_obj.canhit = 0;
            leg1b_obj.canhit = 0;
            head_target_x = x + neck_x + 40;
            head_target_y = y + neck_y + 5;
            alarm[9] = 1;
            alarm[10] = 300;
            head_obj.alarm[9] = 1;
            head_obj.alarm[10] = 280;
            canhit = 0;
            mus_fadeout(musQueen);
            mus_fadeout(musQueen3);
            oMusicV2.bossbgm = sndJump;
            sfx_play(sndQueenDeath);
        }
        queenDead = true;
    }
}

if(oControl.seed != 0 &amp;&amp; !is_undefined(oControl.seed) &amp;&amp; !seedSent){
    seedSent = true;
    buffer_delete(buffer);
    var size, type, alignment;
    size = 1024;
    type = buffer_grow;
    alignment = 1;
    buffer = buffer_create(size, type, alignment);
    buffer_seek(buffer, buffer_seek_start, 0);
    buffer_write(buffer, buffer_u8, 3);
    buffer_write(buffer, buffer_f64, oControl.seed);
    buffer_write(buffer, buffer_u8, global.clientID);
    popup_text("Seed sent");
}

if(keyboard_check_pressed(vk_f2)){
    instance_destroy();
}

/*
if(keyboard_check_pressed(vk_f3)){
    var f = 0;
    repeat(41){
        global.metdead[f] = 1;
        f++;
    }
}
*/
</string>
          </argument>
        </arguments>
      </action>
    </event>
    <event eventtype="7" enumb="68">
      <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>
var type_event = ds_map_find_value(async_load, "type");

switch(type_event){
    case network_type_data:
        var _buffer = ds_map_find_value(async_load, "buffer");
        show_debug_message(buffer_get_size(_buffer));
        buffer_seek(_buffer, buffer_seek_start, 0);
        msgid = buffer_read(_buffer, buffer_u8);
        switch(msgid){
            case 0:
                global.clientID = buffer_read(_buffer, buffer_u8);
                break;
            case 1:
                ds_grid_read(global.onlineReceived, strict_decompress(buffer_read(_buffer, buffer_string)));
                global.receivedClientID = buffer_read(_buffer, buffer_u8);
                if(global.receivedClientID == global.clientID){
                    global.receivedPacketIDs[| global.receivedPacketID] = buffer_read(_buffer, buffer_u32);
                }
                global.receivedPacketID++;
                if(global.receivedClientID != global.clientID){
                    update_variables("disablesame");
                    update_variables("replaceglobalvars");
                    update_variables("updateprev");
                    alarm[0] = 30;
                    ds_grid_clear(global.onlineReceived, -1);
                } 
                break;
            case 2:
                ds_grid_read(global.onlineReceived, strict_decompress(buffer_read(_buffer, buffer_string)));
                global.receivedClientID = buffer_read(_buffer, buffer_u8);
                update_variables("disablesame");
                update_variables("updateprev");
                global.itemChanges = 0;
                global.metdeadChanges = 0;
                global.eventChanges = 0;
                alarm[0] = 30;
                ds_grid_clear(global.onlineReceived, -1);
                break;
            case 3:
                queenHealth = buffer_read(_buffer, buffer_s16);
                var clientID = buffer_read(_buffer, buffer_u8);
                phase = buffer_read(_buffer, buffer_s8);
                state = buffer_read(_buffer, buffer_s8);
                if(clientID != global.clientID){
                    if(!is_undefined(oQueenHead.myhealth) &amp;&amp; !is_undefined(oQueen.phase)){
                        if(oQueen.phase == phase){
                            if(global.queenhealthPrev != queenHealth){
                                global.queenhealthPrev = queenHealth;
                                oQueenHead.myhealth = queenHealth;
                            }
                        }
                        
                        if(global.queenphasePrev != phase){
                            global.queenphasePrev = phase;
                        }
                    } else if(is_undefined(oQueenHead.myhealth) &amp;&amp; is_undefined(oQueen.phase)){
                            queenHealthResetQueued = true;
                            alarm[1] = 5;
                        }
                } else {
                    if(!is_undefined(oQueenHead.myhealth) &amp;&amp; !is_undefined(oQueen.phase)){
                        if(oQueen.phase == phase){
                            if(global.queenhealthPrev != queenHealth){
                                global.queenhealthPrev = queenHealth;
                                oQueenHead.myhealth = queenHealth;
                            }
                        }
                        
                        if(global.queenphasePrev != phase){
                            global.queenphasePrev = phase;
                        }
                        
                    }
                }
                break;
            case 4:
                seed = buffer_read(_buffer, buffer_f64);
                var clientID = buffer_read(_buffer, buffer_u8);
                if(clientID != global.clientID){
                    if(oControl.seed != seed &amp;&amp; !seedReceived){
                        oControl.seed = seed;
                        seedReceived = true;
                        popup_text("Seed received");
                    }
                }
                break;
        }
}


</string>
          </argument>
        </arguments>
      </action>
    </event>
    <event eventtype="7" enumb="3">
      <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>network_destroy(socket);
buffer_delete(buffer);
ds_grid_destroy(global.onlineList);
ds_grid_destroy(global.onlineSend);
ds_grid_destroy(global.onlineReceived);
ds_grid_destroy(global.storedBuffers);
ds_list_destroy(global.receivedPacketIDs);
</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>
