//A/D's Damage Indicator Plugin (with edits by Blaze)
//Displays damage in a more reliable way than Vindicator's plugin. Includes medic target damage support, and
//sentry/generator damage support. All classes are fully supported. (Even reflected rockets!)
//Also, dingaling! DING, DING, DING, DING! Change dingaling.wav for custom dinagling, delete dingaling.wav for none.
out("A/D + Blaze's Damage Indicator Plugin");

if (!variable_global_exists("flameStepAdded")) global.flameStepAdded = 0;
else global.flameStepAdded = 1;

if (global.flameStepAdded == 0) {
if file_exists("Plugins/Sounds/dingaling.wav") {
global.dingaling = 1;
global.dingSound = sound_add("Plugins/Sounds/dingaling.wav", 0, true);
}
else global.dingaling = 0;

global.DamageDealt = object_add();
global.DamageDealtMinor = object_add();
object_set_persistent(global.DamageDealt, true);
object_set_persistent(global.DamageDealtMinor, true);
object_set_sprite(global.DamageDealt, sprite64);
object_set_sprite(global.DamageDealtMinor, SetupGateS);

object_event_add(global.DamageDealt,ev_create,0,'value=0;
alpha=1;
faderate=1;
alarm[1] = 15;
if (global.dingaling == 1){ playsound(x,y,global.dingSound); }');
object_event_add(global.DamageDealt,ev_alarm,1,'faderate = 0.95;');
object_event_add(global.DamageDealt,ev_step,ev_step_normal,'alpha*=faderate; y-=1;
if alpha<0.15 instance_destroy();');
object_event_add(global.DamageDealt,ev_collision,global.DamageDealt,'if (other.id < id && other.owner == owner) {
value+=other.value; alpha=1; with (other) instance_destroy();
}');
object_event_add(global.DamageDealt,ev_collision,global.DamageDealtMinor,'if (other.owner == owner) { value+=other.value;
alpha=1;
with (other) instance_destroy(); }');
object_event_add(global.DamageDealt,ev_draw,0,'draw_set_halign(fa_center);
draw_set_valign(fa_center);
draw_sprite_ext(sprite_index,image_index,x,y,0.7*alpha,0.7*alpha,0,c_white,0);
roundedValue=ceil(value);
draw_set_color(c_red);
draw_set_alpha(alpha);
draw_text(x,y,"-"+string(roundedValue));');

object_event_add(global.DamageDealtMinor,ev_create,0,'value=0; alpha=1;');
object_event_add(global.DamageDealtMinor,ev_step,ev_step_normal,'alpha*=0.95; y-=1.25;
if alpha<0.15 instance_destroy();');
object_event_add(global.DamageDealtMinor,ev_collision,global.DamageDealtMinor,'if (other.id < id && other.owner == owner) {
value+=other.value; alpha=1; with (other) instance_destroy();
}');
object_event_add(global.DamageDealtMinor,ev_draw,0,'draw_set_halign(fa_center);
draw_set_valign(fa_center);
draw_sprite_ext(sprite_index,image_index,x,y,0.8*alpha,0.8*alpha,0,c_white,0);
roundedValue=ceil(value);
{draw_set_color(c_red);
draw_set_alpha(alpha);
draw_text(x,y,"-"+string(roundedValue));}');


object_event_add(Character,ev_alarm,11,'shootsMajor=true;');
object_event_add(Medic,ev_alarm,10,'shootsMajor=true;');
object_event_add(Character,ev_create,0,'shootsMajor=false; alarm[11] = 5;');
object_event_add(Medic,ev_create,0,'shootsMajor=false; alarm[10] = 5;');
with(Character) shootsMajor=true;

object_event_clear(Rifle,ev_other,ev_user1);
object_event_add(Rifle,ev_other,ev_user1,'{    if(readyToShoot == true) {
        playsound(x,y,SniperSnd);
        shot=true;
        justShot=true;        
        readyToShoot = false;
        alarm[0] = reloadTime + 20*owner.zoomed;
        
        var hit;
        var x1,y1,xm,ym, len;
        var hitline;
        len=2000;
        x1=x;
        y1=y;
        x2=x+lengthdir_x(len,owner.aimDirection);
        y2=y+lengthdir_y(len,owner.aimDirection);
        
        while(len>1) {
            xm=(x1+x2)/2;
            ym=(y1+y2)/2;
            
            hitline = false;
            with(owner) {
                if (collision_line(x1,y1,xm,ym,Generator,true,true)>=0) {
                    hitline = true;
                    if instance_nearest(x1,y1,Generator).team == team hitline = false;
                }
                if(collision_line(x1,y1,xm,ym,Obstacle,true,true)>=0) {
                    hitline = true;
                } else if (collision_line(x1,y1,xm,ym,Character,true,true)>=0) {
                    hitline = true;
                } else if (collision_line(x1,y1,xm,ym,Sentry,true,false)>=0) {
                    hitline = true;
                } else if (collision_line(x1,y1,xm,ym,TeamGate,true,true)>=0) {
                    hitline = true;
                } else if (collision_line(x1,y1,xm,ym,IntelGate,true,true)>=0) {
                    hitline = true;
                } else if (collision_line(x1,y1,xm,ym,ControlPointSetupGate,true,true)>=0) {
                    if ControlPointSetupGate.solid == true hitline = true;
                } else if (collision_line(x1,y1,xm,ym,BulletWall,true,true)>=0) {
                    hitline = true;
                } 
            }
            
            if(hitline) {
                x2=xm;
                y2=ym;
            } else {
                x1=xm;
                y1=ym;
            }
            len/=2;
        }
        
        with(Player) {
            if(id != other.ownerPlayer and team != other.owner.team and object != -1) {
                if(collision_line(other.x,other.y,other.x2,other.y2,object,true,false)>=0) && object.ubered == 0 {
                        target = global.myself;
                        if global.myself.object != -1 && global.myself.class == CLASS_MEDIC {
                            if instance_exists(global.myself.object.currentWeapon) {
                                if(global.myself.object.currentWeapon.healTarget != -1 && instance_exists(global.myself.object.currentWeapon.healTarget)){
                                    target = global.myself.object.currentWeapon.healTarget;
                                }
                            }
                        }
                    
                        if other.ownerPlayer=global.myself || other.ownerPlayer=target {
                            var damageDone;
                            damageDone = instance_create(object.x,object.y-15,global.DamageDealt);
                            damageDone.value = other.hitDamage * (global.dmg / 100);
                            damageDone.owner = object.id;
                        }
                    object.hp -= other.hitDamage;
                    object.lastDamageDealer = other.ownerPlayer;
                    object.cloakAlpha = min(object.cloakAlpha + 0.3, 1);
                    object.lastDamageSource = WEAPON_RIFLE;
                    exit;
                }
            }
        }
        
        with(Sentry) {
            if(team != other.owner.team) {
                if(collision_line(other.x,other.y,other.x2,other.y2,id,false,false)>=0) {
                        target = global.myself;
                        if global.myself.object != -1 && global.myself.class == CLASS_MEDIC {
                            if instance_exists(global.myself.object.currentWeapon) {
                                if(global.myself.object.currentWeapon.healTarget != -1 && instance_exists(global.myself.object.currentWeapon.healTarget)){
                                    target = global.myself.object.currentWeapon.healTarget;
                                }
                            }
                        }
                    
                        if other.ownerPlayer=global.myself || other.ownerPlayer=target {
                            var damageDone;
                            damageDone = instance_create(x,y-15,global.DamageDealt);
                            damageDone.value = other.hitDamage * (global.dmg / 100);
                            damageDone.owner = id;
                        }
                    hp -= other.hitDamage;
                    lastDamageDealer = other.ownerPlayer;
                    lastDamageSource = WEAPON_RIFLE;
                    exit;
                }
            }
        }
        
        with(Generator) {
            if(team != other.owner.team) {
                if(collision_line(other.x,other.y,other.x2,other.y2,id,true,false)>=0) {
                        target = global.myself;
                        if global.myself.object != -1 && global.myself.class == CLASS_MEDIC {
                            if instance_exists(global.myself.object.currentWeapon) {
                                if(global.myself.object.currentWeapon.healTarget != -1 && instance_exists(global.myself.object.currentWeapon.healTarget)){
                                    target = global.myself.object.currentWeapon.healTarget;
                                }
                            }
                        }
                    
                        if other.ownerPlayer=global.myself || other.ownerPlayer=target {
                            var damageDone;
                            damageDone = instance_create(x,y-15,global.DamageDealt);
                            damageDone.value = other.hitDamage * (global.dmg / 100);
                            damageDone.owner = id;
                        }
                    hp -= other.hitDamage;
                    exit;
                }
            }
        }
    }
}');

object_event_clear(Flamethrower,ev_other,ev_user2);
object_event_add(Flamethrower,ev_other,ev_user2,'{
    if (readyToBlast && gas >= 66) {
        playsound(x,y,CompressionBlastSnd);
        poof = instance_create(x+lengthdir_x(25,owner.aimDirection),y+lengthdir_y(25,owner.aimDirection),AirBlastO);
        if image_xscale == 1 {
            poof.image_xscale = 1;
            poof.image_angle = owner.aimDirection;
        }
        else {
            poof.image_xscale = -1;
            poof.image_angle = owner.aimDirection+180;
        }
        poof.owner=owner;
        with(poof) {
            motion_add(owner.direction, owner.speed);
        }
            
        with Flame { 
            dir = point_direction(other.x, other.y, x, y);
            dist = point_distance(other.x, other.y, x, y);
            angle = abs((dir-other.owner.aimDirection)+720) mod 360;
            if collision_circle(x,y,25,other.poof,false,true) {
                if sticksTo != -1 {
                    if instance_exists(sticksTo) {
                        if other.owner.team == sticksTo.team instance_destroy();
                    }
                } 
            }
       
        } 
        
        with(Rocket) {
            if(ownerPlayer.team != other.owner.team) {
                dir = point_direction(other.x, other.y, x, y);
                dist = point_distance(other.x, other.y, x, y);
                angle = abs((dir-other.owner.aimDirection)+720) mod 360;
                if collision_circle(x,y,25,other.poof,false,true) {
                    ownerPlayer = other.ownerPlayer;
                    /**/ owner = other.owner;
                    team = other.owner.team;
                    weapon = WEAPON_REFLECTED_ROCKET;
                    hitDamage = 25;
                    explosionDamage = 30;
                    knockback = 8;
                    alarm[0] = 200;
                    alarm[1] = 40;
                    alarm[2] = 80;
                    motion_set(other.owner.aimDirection, speed);
                }
            }
        }
        
        with(Mine) {
            if(ownerPlayer.team != other.owner.team) {
                dir = point_direction(other.x, other.y, x, y);
                dist = point_distance(other.x, other.y, x, y);
                angle = abs((dir-other.owner.aimDirection)+720) mod 360;
                weapon = WEAPON_REFLECTED_STICKY;
                if collision_circle(x,y,25,other.poof,false,true) {
                    motion_add(other.owner.aimDirection, other.blastStrength*(1-dist/other.blastDistance) );
                    stickied = false;
                }
                if(position_meeting(x+hspeed,y+vspeed,Obstacle)) { 
                    motion_add(point_direction(x,y,x-hspeed,y-vspeed),speed*1.4) 
                    stickied = false;
                }  
            }
        }
        
        
        with(Character) {
                dir = point_direction(other.x, other.y, x, y);
                dist = point_distance(other.x, other.y, x, y);
                angle = abs((dir-other.owner.aimDirection)+720) mod 360;
                if collision_circle(x,y,25,other.poof,false,true) {
                    if(team != other.owner.team) {
                        motion_add(other.owner.aimDirection, other.characterBlastStrength*(1-dist/other.blastDistance) );
                        vspeed -= 2;
                        moveStatus = 3;
                    }
            }
        }
        
        with(LooseSheet) {
            dir = point_direction(other.x, other.y, x, y);
            dist = point_distance(other.x, other.y, x, y);
            angle = abs((dir-other.owner.aimDirection)+720) mod 360;
            if collision_circle(x,y,25,other.poof,false,true) {
                motion_add(other.owner.aimDirection, other.blastStrength*(1-dist/other.blastDistance) );
            }
        }
        
        with(Gib) {
            dir = point_direction(other.x, other.y, x, y);
            dist = point_distance(other.x, other.y, x, y);
            angle = abs((dir-other.owner.aimDirection)+720) mod 360;
            if collision_circle(x,y,25,other.poof,false,true) {
                motion_add(other.owner.aimDirection, other.blastStrength*(1-dist/other.blastDistance) );
            }
        }
        
        readyToBlast=false;
        readyToShoot=false;
        alarm[1]=blastReloadTime;
        alarm[0]=blastNoFlameTime;
        gas -= 66;
    }
}');

object_event_clear(Rocket,ev_other,ev_user5);
object_event_add(Rocket,ev_other,ev_user5,'{  
    if(characterHit.id != ownerPlayer.object) {
        if(exploded == true) {
            exit;
        } else {
            exploded = true;
        }
        if(characterHit != -1) {
            if(characterHit.team != team || characterHit.id == ownerPlayer.object  && characterHit.ubered == 0 ) {
                    target = global.myself;
                    if global.myself.object != -1 && global.myself.class == CLASS_MEDIC {
                        if instance_exists(global.myself.object.currentWeapon) {
                            if(global.myself.object.currentWeapon.healTarget != -1 && instance_exists(global.myself.object.currentWeapon.healTarget)){
                                target = global.myself.object.currentWeapon.healTarget;
                            }
                        }
                    }
                if (owner=global.myself.object || owner=target.object) {
                    var damageDone;
                    if owner.shootsMajor=true {
                        damageDone = instance_create(other.x,other.y-15,global.DamageDealt);
                        owner.shootsMajor=false;
                        owner.alarm[11]=10;
                    }
                else damageDone = instance_create(other.x,other.y-15,global.DamageDealtMinor);
                
                damageDone.value = hitDamage * (global.dmg / 100);
                damageDone.owner = characterHit.id;
                }
                
                characterHit.hp -= hitDamage;
                characterHit.lastDamageDealer = ownerPlayer;
                characterHit.lastDamageSource = weapon;
            }
        }
        instance_create(x,y,Explosion);
        playsound(x,y,ExplosionSnd);
        
        with (Character) {
            if (distance_to_object(other) < other.blastRadius){
                //if(other.team != team or id==other.ownerPlayer.object) {
                    motion_add(point_direction(other.x,other.y,x,y),other.knockback-other.knockback*(distance_to_object(other)/other.blastRadius));
                //}
                if(other.team != team or id==other.ownerPlayer.object) && ubered == 0 && hp > 0 {
                        target = global.myself;
                        if global.myself.object != -1 && global.myself.class == CLASS_MEDIC {
                            if instance_exists(global.myself.object.currentWeapon) {
                                if(global.myself.object.currentWeapon.healTarget != -1 && instance_exists(global.myself.object.currentWeapon.healTarget)){
                                    target = global.myself.object.currentWeapon.healTarget;
                                }
                            }
                        }
                    if ((other.owner=global.myself.object && id!=global.myself.object && other.team!=team) || (other.owner=target.object && id!=target.object && other.team!=team)) {
                        var damageDone;
                        if other.owner.shootsMajor=true {
                            damageDone = instance_create(x,y-15,global.DamageDealt);
                            other.owner.shootsMajor=false;
                            other.owner.alarm[11]=10;
                        }
                        else damageDone = instance_create(x,y-15,global.DamageDealtMinor);
                        damageDone.value = (other.explosionDamage * (global.dmg / 100))*(1-(distance_to_object(other)/other.blastRadius));
                        damageDone.owner = id;
                    }
                    hp -= other.explosionDamage*(1-(distance_to_object(other)/other.blastRadius));
                    lastDamageDealer = other.ownerPlayer;
                    lastDamageSource = other.weapon;
                    if id==other.ownerPlayer.object and other.team == team {
                        moveStatus = 1;
                        speed*=1.06;
                        hp+=(other.explosionDamage*(1-(distance_to_object(other)/other.blastRadius)))/3;
                    } else {
                        moveStatus = 2;
                        if point_direction(x,y+5,other.x,other.y-5)>210 and point_direction(x,y,other.x,other.y)<330 {
                            vspeed-=4*(1-(distance_to_object(other)/other.blastRadius));
                            speed*=1.3;
                        }
                    }
                    if(global.gibLevel > 0){
                        repeat(3) {
                            var blood;
                            blood = instance_create(x,y,Blood);
                            blood.direction = point_direction(other.x,other.y,x,y)-180;
                        }
                    }
                cloakAlpha = min(cloakAlpha + 0.1, 1);
                }
            }
        }

        with (Sentry) {
            if (distance_to_object(other) < other.blastRadius){
                if(other.team != team) {
                        target = global.myself;
                        if global.myself.object != -1 && global.myself.class == CLASS_MEDIC {
                            if instance_exists(global.myself.object.currentWeapon) {
                                if(global.myself.object.currentWeapon.healTarget != -1 && instance_exists(global.myself.object.currentWeapon.healTarget)){
                                    target = global.myself.object.currentWeapon.healTarget;
                                }
                            }
                        }
                    if (other.owner=global.myself.object || other.owner=target.object) {
                        var damageDone;
                        if other.owner.shootsMajor=true {
                            damageDone = instance_create(x,y-15,global.DamageDealt);
                            other.owner.shootsMajor=false;
                            other.owner.alarm[11]=10;
                        }
                        else damageDone = instance_create(x,y-15,global.DamageDealtMinor);
                        damageDone.value = (other.explosionDamage * (global.dmg / 100))*(1-(distance_to_object(other)/other.blastRadius));
                        damageDone.owner = id;
                    }
                    hp -= other.explosionDamage*(1-(distance_to_object(other)/other.blastRadius));
                    lastDamageDealer = other.ownerPlayer;
                    lastDamageSource = other.weapon;
                }
            }
        }        
        
        with (Generator) {
            if (distance_to_object(other) < other.blastRadius){
                if(other.team != team) {
                        target = global.myself;
                        if global.myself.object != -1 && global.myself.class == CLASS_MEDIC {
                            if instance_exists(global.myself.object.currentWeapon) {
                                if(global.myself.object.currentWeapon.healTarget != -1 && instance_exists(global.myself.object.currentWeapon.healTarget)){
                                    target = global.myself.object.currentWeapon.healTarget;
                                }
                            }
                        }
                    if (other.owner=global.myself.object || other.owner=target.object) {
                        var damageDone;
                        if other.owner.shootsMajor=true {
                            damageDone = instance_create(x,y-15,global.DamageDealt);
                            other.owner.shootsMajor=false;
                            other.owner.alarm[11]=10;
                        }
                        else damageDone = instance_create(x,y-15,global.DamageDealtMinor);
                        damageDone.value = (other.explosionDamage * (global.dmg / 100))*(1-(distance_to_object(other)/other.blastRadius));
                        damageDone.owner = id;
                    }
                    hp -= other.explosionDamage*(1-(distance_to_object(other)/other.blastRadius));
                    lastDamageDealer = other.ownerPlayer;
                    lastDamageSource = other.weapon;
                }
            }
        }
            
        /*with (Rocket) {
          if (distance_to_object(other) < other.blastRadius){
            if(distance_to_object(other) < other.blastRadius*0.66 and (other.team != team or other.ownerPlayer == ownerPlayer)) {
                characterHit = -1;
                event_user(5);
            } else {
                motion_add(point_direction(other.x,other.y,x,y),12-12*(distance_to_object(other)/other.blastRadius));
            }
          }
        }*/
        
        with (DeadGuy) {
          if (distance_to_object(other) < other.blastRadius){
            motion_add(point_direction(other.x,other.y,x,y),10-10*(distance_to_object(other)/other.blastRadius));
          }
        }
        
        with (Gib) {
            if (distance_to_object(other) < other.blastRadius){
                motion_add(point_direction(other.x,other.y,x,y),15-15*(distance_to_object(other)/other.blastRadius));
                rotspeed=random(151)-75;
            }
        }
    
        with(Mine) {
            if (distance_to_object(other) < other.blastRadius*0.66 and (other.team != team or other.ownerPlayer == ownerPlayer)){
                event_user(2);
            }
        }
        
        with(LooseSheet) {
            if (distance_to_object(other) < other.blastRadius){
                motion_add(point_direction(other.x,other.y,x,y),10-10*(distance_to_object(other)/other.blastRadius));
            }
        }
        
        with(Bubble) {
            if (distance_to_object(other) < other.blastRadius*0.66){
                alarm[0]-=200;
            }    
        }

        instance_destroy();
    }
}');

object_event_clear(Mine,ev_other,ev_user2);
object_event_add(Mine,ev_other,ev_user2,'{
    if(exploded == true) {
        exit;
    } else {
        exploded = true;
    }
    instance_create(x,y,Explosion);
    //effect_create_below(ef_explosion,x,y,0,c_orange);
    playsound(x,y,ExplosionSnd);
    
    with (Character) {
        if (distance_to_object(other) < other.blastRadius){
            motion_add(point_direction(other.x,other.y,x,y),10-10*(distance_to_object(other)/other.blastRadius));
            if(other.team != team or id==other.ownerPlayer.object) && ubered == 0 && hp > 0 {
                    target = global.myself;
                    if global.myself.object != -1 && global.myself.class == CLASS_MEDIC {
                        if instance_exists(global.myself.object.currentWeapon) {
                            if(global.myself.object.currentWeapon.healTarget != -1 && instance_exists(global.myself.object.currentWeapon.healTarget)){
                                target = global.myself.object.currentWeapon.healTarget;
                            }
                        }
                    }
                if ((other.owner=global.myself.object && id!=global.myself.object && other.team!=team) || (other.owner=target.object && id!=target.object && other.team!=team)) {
                    var damageDone;
                    if other.owner.shootsMajor=true {
                        damageDone = instance_create(x,y-15,global.DamageDealt);
                        other.owner.shootsMajor=false;
                        other.owner.alarm[11]=10;
                    }
                    else damageDone = instance_create(x,y-15,global.DamageDealtMinor);
                    damageDone.value = (other.explosionDamage * (global.dmg / 100))*(1-(distance_to_object(other)/other.blastRadius));
                    damageDone.owner = id;
                }
                hp -= other.explosionDamage*(1-(distance_to_object(other)/other.blastRadius));
                lastDamageDealer = other.ownerPlayer;
                lastDamageSource = other.weapon;
                if(global.gibLevel > 0){
                repeat(3) {
                    var blood;
                    blood = instance_create(x,y,Blood);
                    blood.direction = point_direction(other.x,other.y,x,y)-180;}
                }
                if id==other.ownerPlayer.object and other.team == team {
                    moveStatus = 1;
                    vspeed*=0.8;
                }
            }
            cloakAlpha = min(cloakAlpha + 0.2, 1);
        }
    }

    
    with (Sentry){
        if (distance_to_object(other) < other.blastRadius) && (team != other.team) {
            target = global.myself;
            if global.myself.object != -1 && global.myself.class == CLASS_MEDIC {
                if instance_exists(global.myself.object.currentWeapon) {
                    if(global.myself.object.currentWeapon.healTarget != -1 && instance_exists(global.myself.object.currentWeapon.healTarget)){
                        target = global.myself.object.currentWeapon.healTarget;
                    }
                }
            }
        if (other.owner=global.myself.object || other.owner=target.object) {
            var damageDone;
            if other.owner.shootsMajor=true {
                damageDone = instance_create(x,y-15,global.DamageDealt);
                other.owner.shootsMajor=false;
                other.owner.alarm[11]=10;
            }
            else damageDone = instance_create(x,y-15,global.DamageDealtMinor);
            damageDone.value = (other.explosionDamage * (global.dmg / 100))*(1-(distance_to_object(other)/other.blastRadius));
            damageDone.owner = id;
        }
        hp -= other.explosionDamage*(1-(distance_to_object(other)/other.blastRadius));
        }   
    }    
     
     with (Generator){
        if (distance_to_object(other) < other.blastRadius) && (team != other.team) {
            target = global.myself;
            if global.myself.object != -1 && global.myself.class == CLASS_MEDIC {
                if instance_exists(global.myself.object.currentWeapon) {
                    if(global.myself.object.currentWeapon.healTarget != -1 && instance_exists(global.myself.object.currentWeapon.healTarget)){
                        target = global.myself.object.currentWeapon.healTarget;
                    }
                }
            }
        if (other.owner=global.myself.object || other.owner=target.object) {
            var damageDone;
            if other.owner.shootsMajor=true {
                damageDone = instance_create(x,y-15,global.DamageDealt);
                other.owner.shootsMajor=false;
                other.owner.alarm[11]=10;
            }
            else damageDone = instance_create(x,y-15,global.DamageDealtMinor);
            damageDone.value = (other.explosionDamage * (global.dmg / 100))*(1-(distance_to_object(other)/other.blastRadius));
            damageDone.owner = id;
        }
        hp -= other.explosionDamage*(1-(distance_to_object(other)/other.blastRadius));
        }   
    }
       
    with (Rocket) {
        if (distance_to_object(other) < other.blastRadius/4){
            if(distance_to_object(other) < other.blastRadius/7 and (other.team != team or other.ownerPlayer == ownerPlayer)) {
                characterHit=-1;
                event_user(5);
            } else {
                motion_add(point_direction(other.x,other.y,x,y),10-10*(distance_to_object(other)/(other.blastRadius*5)));
            }
        }
    }
    
    with (DeadGuy) {
        if (distance_to_object(other) < other.blastRadius){
            motion_add(point_direction(other.x,other.y,x,y),10-10*(distance_to_object(other)/other.blastRadius));
        }
    }
    
    with(Mine) {
        if (distance_to_object(other) < other.blastRadius*0.66 and (other.team != team or other.ownerPlayer == ownerPlayer)){
            event_user(2);
        }
    }
    with (Gib) {
        if (distance_to_object(other) < other.blastRadius){
            motion_add(point_direction(other.x,other.y,x,y),15-15*(distance_to_object(other)/other.blastRadius));
            rotspeed=random(151)-75;
        }
    }
    
    with(LooseSheet) {
        if (distance_to_object(other) < other.blastRadius){
            motion_add(point_direction(other.x,other.y,x,y),10-10*(distance_to_object(other)/other.blastRadius));
        }
    }
    with(Bubble) {
        if (distance_to_object(other) < other.blastRadius*0.66){
        alarm[0]-=200;
        }    
    }

    instance_destroy();
}');

object_event_clear(SentryTurret,ev_step,ev_step_end);
object_event_add(SentryTurret,ev_step,ev_step_end,'var targetQueue, testDist, playercheck, targetAngle, obscured, rotateoffset;

if ownerPlayer.sentry != -1 {
    if x != ownerPlayer.sentry.x x = ownerPlayer.sentry.x;
    if y != ownerPlayer.sentry.y y = ownerPlayer.sentry.y;
}
else if ownerPlayer.sentry == -1 instance_destroy();

if(((direction+270) mod 360)>180) {
    image_xscale=1;
    image_angle = direction;
} else {
    image_xscale=-1;
    image_angle = direction+180;
}

nearestTarget = -1;
targetQueue = ds_priority_create();

// Build a queue of potential targets
with(Character) {
    testDist = distance_to_object(other);
    if(!cloak && testDist<=375) {
        ds_priority_add(targetQueue, id, testDist);
    }
}

with(Sentry) {
    testDist = distance_to_object(other);
    if(testDist<=375) {
        ds_priority_add(targetQueue, id, testDist);
    }
}

with(Generator) {
    testDist = distance_to_object(other);
    if(testDist<=375) {
        ds_priority_add(targetQueue, id, testDist);
    }
}

while(nearestTarget == -1 && !ds_priority_empty(targetQueue)) {
    playercheck = ds_priority_delete_min(targetQueue);
    targetAngle = point_direction(x,y,playercheck.x,playercheck.y);
    if((targetAngle <= 45 || targetAngle >= 315 || (targetAngle >= 135 && targetAngle <= 225) || place_meeting(x,y,playercheck)) 
            && playercheck.team != team 
            && playercheck.hp > 0
            && collision_line(x,y,playercheck.x,playercheck.y,Obstacle,true,true)<0
            && collision_line(x,y,playercheck.x,playercheck.y,TeamGate,true,true)<0
            && collision_line(x,y,playercheck.x,playercheck.y,ControlPointSetupGate,true,true)<0
            && collision_line(x,y,playercheck.x,playercheck.y,IntelGate,true,true)<0
            && collision_line(x,y,playercheck.x,playercheck.y,BulletWall,true,true)<0) {
        // Target looks valid, but it might be obscured by a sentry.
        // That has to be tested individually because we have to exclude both this sentry and the target
        // from the collision check
        obscured = false;
        with(Sentry) {
            if(!obscured && id != other.ownerPlayer.sentry && id != playercheck && collision_line(other.x,other.y,playercheck.x,playercheck.y,id,false,false)>=0) {
                obscured = true;
            }
        }
        if(!obscured) {
            nearestTarget = playercheck;
        }
    }
}

ds_priority_destroy(targetQueue);

if(nearestTarget == -1) {
    noticedTarget = true;
    if image_xscale != startDirection {
        rotating=true;
    }
} else {
    with(Spy) {
        if(team != other.team && collision_line(other.x,other.y,other.nearestTarget.x,other.nearestTarget.y,id,true,false)>=0) {
            other.nearestTarget = id;
        }
    }
    
    if(nearestTarget.x < x && image_xscale == 1) {
        rotating=true;
    } else if(nearestTarget.x > x && image_xscale == -1) {
        rotating=true;
    }    
        
    if (noticedTarget == true) {
        playsound(x,y,SentryAlert);
        readyToShoot = false;
        alarm[0] = reloadTime*2;
    }    
    
    noticedTarget = false;
    
    if(readyToShoot && (rotating == false)) {
        direction = point_direction(x,y,nearestTarget.x,nearestTarget.y);
        
        // Prevent the turret from turning too high even if it is shooting in that direction.
        // This hides the exception to the angle restriction that occurs when a player is standing
        // directly on the sentry gun. 
        if(direction>45 and direction<90) direction=45;
        else if(direction<135 and direction>90) direction=135;
        else if(direction>225 and direction<270) direction=225;
        else if(direction<315 and direction>270) direction=315;
        
        playsound(x,y,ShotgunSnd);
        ownerPlayer.sentry.idleTimer = false;
        ownerPlayer.sentry.alarm[5] = 30;
        target = global.myself;
        if global.myself.object != -1 && global.myself.class == CLASS_MEDIC {
            if instance_exists(global.myself.object.currentWeapon) {
                if(global.myself.object.currentWeapon.healTarget != -1 && instance_exists(global.myself.object.currentWeapon.healTarget)){
                    target = global.myself.object.currentWeapon.healTarget;
                }
            }
        }
            if (ownerPlayer=global.myself || ownerPlayer=target) {
                var damageDone;
                damageDone = instance_create(nearestTarget.x,nearestTarget.y-15,global.DamageDealt);
                damageDone.value = hitDamage * (global.dmg / 100);
                damageDone.owner = nearestTarget.id;
            }
        
        if(nearestTarget.ubered == 0) {
            nearestTarget.hp -= hitDamage;
            nearestTarget.lastDamageDealer = ownerPlayer;
            nearestTarget.lastDamageSource = WEAPON_SENTRYTURRET;
            if(global.gibLevel = 0 && object_is_ancestor(nearestTarget, Character)){
                blood = instance_create(nearestTarget.x,nearestTarget.y,Blood);
                blood.direction = direction-180;
            }
        }
        shooting=true;
        justShot=true;  
        readyToShoot=false;
        alarm[0]=reloadTime;
    }
}

if(rotating) {
    rotateindex += 0.3;
    if(rotateindex >= rotateend) {
        image_xscale = -image_xscale;
        direction += 180;
        rotating = false;
        rotateindex = rotatestart;
    }
}');

object_event_clear(Shot,ev_collision,Character);
object_event_clear(Shot,ev_collision,Sentry);
object_event_clear(Shot,ev_collision,Generator);

object_event_add(Shot,ev_collision,Character,'if(other.id != ownerPlayer.object and other.team != team  && other.hp > 0 && other.ubered == 0) {
    //
    target = global.myself;
    if global.myself.object != -1 && global.myself.class == CLASS_MEDIC {
        if instance_exists(global.myself.object.currentWeapon) {
            if(global.myself.object.currentWeapon.healTarget != -1 && instance_exists(global.myself.object.currentWeapon.healTarget)){
                target = global.myself.object.currentWeapon.healTarget;
            }
        }
    }
    if (owner=global.myself.object || owner=target.object) {
        var damageDone;                
        if owner.shootsMajor=true && (weapon = WEAPON_SCATTERGUN || weapon = WEAPON_SHOTGUN) {
            damageDone = instance_create(other.x,other.y-15,global.DamageDealt);
            owner.shootsMajor=false;
            owner.alarm[11]=10;
        }
        else if owner.shootsMajor=true && weapon = WEAPON_MINIGUN {
            damageDone = instance_create(other.x,other.y-15,global.DamageDealt);
            owner.shootsMajor=false;
            owner.alarm[11]=8;
        }
        else if owner.shootsMajor=true && weapon = WEAPON_REVOLVER {
            damageDone = instance_create(other.x,other.y-15,global.DamageDealt);
            owner.shootsMajor=false;
            owner.alarm[11]=4;
        }
        else damageDone = instance_create(other.x,other.y-15,global.DamageDealtMinor);
        damageDone.value = damage * (global.dmg / 100);
        damageDone.owner = other.id;
    }
    other.hp -= damage;
    other.lastDamageDealer = ownerPlayer;
    other.lastDamageSource = weapon;
    var blood;
    if(global.gibLevel > 0){
        blood = instance_create(x,y,Blood);
        blood.direction = direction-180;
    }
            
    with(other) {
        motion_add(other.direction, other.speed*0.03);
        cloakAlpha = min(cloakAlpha + 0.1, 1);    
    }
    instance_destroy();
}
');
object_event_add(Shot,ev_collision,Sentry,'if(other.team != team) {
    target = global.myself;
    if global.myself.object != -1 && global.myself.class == CLASS_MEDIC {
        if instance_exists(global.myself.object.currentWeapon) {
            if(global.myself.object.currentWeapon.healTarget != -1 && instance_exists(global.myself.object.currentWeapon.healTarget)){
                target = global.myself.object.currentWeapon.healTarget;
            }
        }
    }
    if (owner=global.myself.object || owner=target.object) {
        var damageDone;                
        if owner.shootsMajor=true && (weapon = WEAPON_SCATTERGUN || weapon = WEAPON_SHOTGUN) {
            damageDone = instance_create(other.x,other.y-15,global.DamageDealt);
            owner.shootsMajor=false;
            owner.alarm[11]=10;
        }
        else if owner.shootsMajor=true && weapon = WEAPON_MINIGUN {
            damageDone = instance_create(other.x,other.y-15,global.DamageDealt);
            owner.shootsMajor=false;
            owner.alarm[11]=8;
        }
        else if owner.shootsMajor=true && weapon = WEAPON_REVOLVER {
            damageDone = instance_create(other.x,other.y-15,global.DamageDealt);
            owner.shootsMajor=false;
            owner.alarm[11]=4;
        }
        else damageDone = instance_create(other.x,other.y-15,global.DamageDealtMinor);
        damageDone.value = damage * (global.dmg / 100);
        damageDone.owner = other.id;
    }
    other.hp -= damage;
    instance_destroy();
    }');
object_event_add(Shot,ev_collision,Generator,'if(other.team != team) {
        target = global.myself;
        if global.myself.object != -1 && global.myself.class == CLASS_MEDIC {
            if instance_exists(global.myself.object.currentWeapon) {
                if(global.myself.object.currentWeapon.healTarget != -1 && instance_exists(global.myself.object.currentWeapon.healTarget)){
                    target = global.myself.object.currentWeapon.healTarget;
                }
            }
        }
        if (owner=global.myself.object || owner=target.object) {
            var damageDone;                
            if owner.shootsMajor=true && (weapon = WEAPON_SCATTERGUN || weapon = WEAPON_SHOTGUN) {
                damageDone = instance_create(other.x,other.y-15,global.DamageDealt);
                owner.shootsMajor=false;
                owner.alarm[11]=10;
            }
            else if owner.shootsMajor=true && weapon = WEAPON_MINIGUN {
                damageDone = instance_create(other.x,other.y-15,global.DamageDealt);
                owner.shootsMajor=false;
                owner.alarm[11]=8;
            }
            else if owner.shootsMajor=true && weapon = WEAPON_REVOLVER {
                damageDone = instance_create(other.x,other.y-15,global.DamageDealt);
                owner.shootsMajor=false;
                owner.alarm[11]=4;
            }
            else damageDone = instance_create(other.x,other.y-15,global.DamageDealtMinor);
            damageDone.value = damage * (global.dmg / 100);
            damageDone.owner = other.id;
        }
    other.hp -= damage;
    instance_destroy();
}');

object_event_add(Flame,ev_step,0,'if (sticksTo != -1) {
	if(instance_exists(sticksTo)) { 
            if sticksTo.ubered == 0 && sticksTo.hp > 0{
                    target = global.myself;
                    if global.myself.object != -1 && global.myself.class == CLASS_MEDIC {
                        if instance_exists(global.myself.object.currentWeapon) {
                            if(global.myself.object.currentWeapon.healTarget != -1 && instance_exists

(global.myself.object.currentWeapon.healTarget)){
                                target = global.myself.object.currentWeapon.healTarget;
                            }
                        }
                    }
                if(instance_exists(owner) && owner != -1 && (owner = global.myself.object || owner=target.object)) {
                    var damageDone;                
                    if owner.shootsMajor=true {
                        damageDone = instance_create(other.x,other.y-15,global.DamageDealt);
                        owner.shootsMajor=false;
                        owner.alarm[11]=10;
                    }
                    else damageDone = instance_create(other.x,other.y-15,global.DamageDealtMinor);
                    damageDone.value = burnDamage * (global.dmg / 100);
                    damageDone.owner = sticksTo.id;
                }
}}}');

object_event_clear(Flame,ev_collision,Character);
object_event_clear(Flame,ev_collision,Sentry);
object_event_clear(Flame,ev_collision,Generator);

object_event_add(Flame,ev_collision,Character,'if(sticksTo == -1 and other.id != ownerPlayer.object and other.team != team && other.ubered == 0  && other.hp > 0) {
    target = global.myself;
    if global.myself.object != -1 && global.myself.class == CLASS_MEDIC {
        if instance_exists(global.myself.object.currentWeapon) {
            if(global.myself.object.currentWeapon.healTarget != -1 && instance_exists(global.myself.object.currentWeapon.healTarget)){
                target = global.myself.object.currentWeapon.healTarget;
            }
        }
    }
    if (owner=global.myself.object || owner=target.object) {
        var damageDone;                
        if owner.shootsMajor=true {
            damageDone = instance_create(other.x,other.y-15,global.DamageDealt);
            owner.shootsMajor=false;
            owner.alarm[11]=10;
        }
        else damageDone = instance_create(other.x,other.y-15,global.DamageDealtMinor);
        damageDone.value = hitDamage * (global.dmg / 100);
        damageDone.owner = other.id;
    }
    other.hp -= hitDamage;
    other.lastDamageDealer = ownerPlayer;
    other.lastDamageSource = weapon;
    if(object_is_ancestor(other.object_index, Pyro) or other.ubered == 1) {
        instance_destroy();
    } else {
        if(other.flamecount>7) {
            var character;
            character = other.id;
            with(Flame) {
                if(sticksTo == character) {
                    instance_destroy();
                    break;
                }
            }
        }
        sticksTo = other.id;
        stickRelativeX = x-other.x;
        stickRelativeY = y-other.y;
        speed=0;
        alarm[0]=150;
        other.flamecount += 1;
    }
}');

object_event_add(Flame,ev_collision,Sentry,'if(other.team != team and sticksTo = -1) {
    target = global.myself;
    if global.myself.object != -1 && global.myself.class == CLASS_MEDIC {
        if instance_exists(global.myself.object.currentWeapon) {
            if(global.myself.object.currentWeapon.healTarget != -1 && instance_exists(global.myself.object.currentWeapon.healTarget)){
                target = global.myself.object.currentWeapon.healTarget;
            }
        }
    }
    if (owner=global.myself.object || owner=target.object) {
        var damageDone;                
        if owner.shootsMajor=true {
            damageDone = instance_create(other.x,other.y-15,global.DamageDealt);
            owner.shootsMajor=false;
            owner.alarm[11]=10;
        }
        else damageDone = instance_create(other.x,other.y-15,global.DamageDealtMinor);
        damageDone.value = hitDamage * (global.dmg / 100);
        damageDone.owner = other.id;
    }
    //
    other.hp -= hitDamage;
    instance_destroy();
}');

object_event_add(Flame,ev_collision,Generator,'if(other.team != team and sticksTo = -1) {
    target = global.myself;
    if global.myself.object != -1 && global.myself.class == CLASS_MEDIC {
        if instance_exists(global.myself.object.currentWeapon) {
            if(global.myself.object.currentWeapon.healTarget != -1 && instance_exists(global.myself.object.currentWeapon.healTarget)){
                target = global.myself.object.currentWeapon.healTarget;
            }
        }
    }
    if (owner=global.myself.object || owner=target.object) {
        var damageDone;                
        if owner.shootsMajor=true {
            damageDone = instance_create(other.x,other.y-15,global.DamageDealt);
            owner.shootsMajor=false;
            owner.alarm[11]=10;
        }
        else damageDone = instance_create(other.x,other.y-15,global.DamageDealtMinor);
        damageDone.value = hitDamage * (global.dmg / 100);
        damageDone.owner = other.id;
    }
    other.hp -= hitDamage;
    instance_destroy();
}');

object_event_clear(Needle,ev_collision,Character);
object_event_clear(Needle,ev_collision,Sentry);
object_event_clear(Needle,ev_collision,Generator);

object_event_add(Needle,ev_collision,Character,'if(other.id != ownerPlayer.object and other.team != team  && other.hp > 0 && other.ubered == 0) {
    target = global.myself;
    if global.myself.object != -1 && global.myself.class == CLASS_MEDIC {
        if instance_exists(global.myself.object.currentWeapon) {
            if(global.myself.object.currentWeapon.healTarget != -1 && instance_exists(global.myself.object.currentWeapon.healTarget)){
                target = global.myself.object.currentWeapon.healTarget;
            }
        }
    }
    if (owner=global.myself.object || owner=target.object) {
        var damageDone;                
        if owner.shootsMajor=true {
            damageDone = instance_create(other.x,other.y-15,global.DamageDealt);
            owner.shootsMajor=false;
            owner.alarm[10]=8;
        }
        else damageDone = instance_create(other.x,other.y-15,global.DamageDealtMinor);
        damageDone.value = hitDamage * (global.dmg / 100);
        damageDone.owner = other.id;
    }
    other.hp -= hitDamage;
    other.lastDamageDealer = ownerPlayer;
    other.lastDamageSource = weapon;
    var blood;
    if(global.gibLevel > 0){
        blood = instance_create(x,y,Blood);
        blood.direction = direction-180;
        }
    with(other) {
        motion_add(other.direction, other.speed*0.03);
        cloakAlpha = min(cloakAlpha + 0.1, 1);
    }
    instance_destroy();
}');

object_event_add(Needle,ev_collision,Sentry,'if(other.team != team) {
target = global.myself;
if global.myself.object != -1 && global.myself.class == CLASS_MEDIC {
    if instance_exists(global.myself.object.currentWeapon) {
        if(global.myself.object.currentWeapon.healTarget != -1 && instance_exists(global.myself.object.currentWeapon.healTarget)){
            target = global.myself.object.currentWeapon.healTarget;
        }
    }
}
if (owner=global.myself.object || owner=target.object) {
    var damageDone;                
    if owner.shootsMajor=true {
        damageDone = instance_create(other.x,other.y-15,global.DamageDealt);
        owner.shootsMajor=false;
        owner.alarm[10]=8;
    }
    else damageDone = instance_create(other.x,other.y-15,global.DamageDealtMinor);
    damageDone.value = hitDamage * (global.dmg / 100);
    damageDone.owner = other.id;
}
other.hp -= hitDamage;
instance_destroy();
}');

object_event_add(Needle,ev_collision,Generator,'if(other.team != team) {
    target = global.myself;
    if global.myself.object != -1 && global.myself.class == CLASS_MEDIC {
        if instance_exists(global.myself.object.currentWeapon) {
            if(global.myself.object.currentWeapon.healTarget != -1 && instance_exists(global.myself.object.currentWeapon.healTarget)){
                target = global.myself.object.currentWeapon.healTarget;
            }
        }
    }
    if (owner=global.myself.object || owner=target.object) {
        var damageDone;                
        if owner.shootsMajor=true {
            damageDone = instance_create(other.x,other.y-15,global.DamageDealt);
            owner.shootsMajor=false;
            owner.alarm[10]=8;
        }
        else damageDone = instance_create(other.x,other.y-15,global.DamageDealtMinor);
        damageDone.value = hitDamage * (global.dmg / 100);
        damageDone.owner = other.id;
    }
    other.hp -= hitDamage;
    instance_destroy();
}');

object_event_clear(BladeB,ev_collision,Character);
object_event_clear(BladeB,ev_collision,Sentry);
object_event_clear(BladeB,ev_collision,Generator);

object_event_add(BladeB,ev_collision,Character,'{
    if(other.id != ownerPlayer.object and other.team != team) {
        if other.ubered == 0 {
                target = global.myself;
                if global.myself.object != -1 && global.myself.class == CLASS_MEDIC {
                    if instance_exists(global.myself.object.currentWeapon) {
                        if(global.myself.object.currentWeapon.healTarget != -1 && instance_exists(global.myself.object.currentWeapon.healTarget)){
                            target = global.myself.object.currentWeapon.healTarget;
                        }
                    }
                }
            if (owner=global.myself.object || owner=target.object) {
                var damageDone;                
                if owner.shootsMajor=true {
                    damageDone = instance_create(other.x,other.y-15,global.DamageDealt);
                    owner.shootsMajor=false;
                    owner.alarm[11]=3;
                }
                else damageDone = instance_create(other.x,other.y-15,global.DamageDealtMinor);
                damageDone.value = hitDamage * (global.dmg / 100);
                damageDone.owner = other.id;
            }
            other.hp -= hitDamage;
            other.lastDamageDealer = ownerPlayer;
            other.lastDamageSource = weapon;
            var blood;
            if(global.gibLevel > 0){
            repeat(25) {
                blood = instance_create(x,y,Blood);
                blood.direction = direction-180;
                }
            }
        }
        with(other) {
            motion_add(other.direction, other.speed*0.4);
            cloakAlpha = min(cloakAlpha + 0.1, 1);
        }
        with owner.currentWeapon BladesOut -= 1;
        instance_destroy();
    }
}');

object_event_add(BladeB,ev_collision,Sentry,'if(other.team != team) {
    target = global.myself;
    if global.myself.object != -1 && global.myself.class == CLASS_MEDIC {
        if instance_exists(global.myself.object.currentWeapon) {
            if(global.myself.object.currentWeapon.healTarget != -1 && instance_exists(global.myself.object.currentWeapon.healTarget)){
                target = global.myself.object.currentWeapon.healTarget;
            }
        }
    }
if (owner=global.myself.object || owner=target.object) {
    var damageDone;                
    if owner.shootsMajor=true {
        damageDone = instance_create(other.x,other.y-15,global.DamageDealt);
        owner.shootsMajor=false;
        owner.alarm[11]=3;
    }
    else damageDone = instance_create(other.x,other.y-15,global.DamageDealtMinor);
    damageDone.value = hitDamage * (global.dmg / 100);
    damageDone.owner = other.id;
}
other.hp -= hitDamage;
with owner.currentWeapon BladesOut -= 1;
instance_destroy();
}');

object_event_add(BladeB,ev_collision,Generator,'if(other.team != team) {
        target = global.myself;
        if global.myself.object != -1 && global.myself.class == CLASS_MEDIC {
            if instance_exists(global.myself.object.currentWeapon) {
                if(global.myself.object.currentWeapon.healTarget != -1 && instance_exists(global.myself.object.currentWeapon.healTarget)){
                    target = global.myself.object.currentWeapon.healTarget;
                }
            }
        }
    if (owner=global.myself.object || owner=target.object) {
        var damageDone;                
        if owner.shootsMajor=true {
            damageDone = instance_create(other.x,other.y-15,global.DamageDealt);
            owner.shootsMajor=false;
            owner.alarm[11]=3;
        }
        else damageDone = instance_create(other.x,other.y-15,global.DamageDealtMinor);
        damageDone.value = hitDamage * (global.dmg / 100);
        damageDone.owner = other.id;
    }
    other.hp -= hitDamage;
    with owner.currentWeapon BladesOut -= 1;
    instance_destroy();
}');

object_event_clear(StabMask,ev_collision,Character);
object_event_clear(StabMask,ev_collision,Sentry);

object_event_add(StabMask,ev_collision,Character,'if(other.id != ownerPlayer.object and other.team != team  && other.hp > 0 && other.ubered == 0) {
    if (owner=global.myself.object) {
        var damageDone;
        damageDone = instance_create(other.x,other.y-15,global.DamageDealt);
        damageDone.value = hitDamage;
        damageDone.owner = other;
    }
    other.hp -= hitDamage;
    other.lastDamageDealer = ownerPlayer;
    other.lastDamageSource = weapon;
    var blood;
    if(global.gibLevel > 0){
        repeat(70){
        blood = instance_create(x,y,Blood);
        blood.direction = direction-180;
        }
    }
instance_destroy();
}');

object_event_add(StabMask,ev_collision,Sentry,'if(other.team != team) {
    if (owner=global.myself.object) {
        var damageDone;
        damageDone = instance_create(other.x,other.y-15,global.DamageDealt);
        damageDone.value = hitDamage;
        damageDone.owner = global.myself.object;
    }
other.hp -= hitDamage;
instance_destroy();
}');
}