2018-05-29 00:08:30 -04:00
|
|
|
#
|
|
|
|
# Copyright (C) 2018 Sage Vaillancourt, sagev9000@gmail.com
|
|
|
|
#
|
|
|
|
# This file is part of Fronter.
|
|
|
|
#
|
|
|
|
# Fronter is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# Fronter is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with Fronter. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
#
|
|
|
|
|
2018-05-27 19:22:11 -04:00
|
|
|
extends Area2D
|
|
|
|
|
|
|
|
signal dead
|
|
|
|
signal flash
|
2018-05-29 00:08:30 -04:00
|
|
|
signal boss_fight_over
|
2018-06-03 11:11:27 -04:00
|
|
|
signal boss_health
|
2018-05-27 19:22:11 -04:00
|
|
|
export (PackedScene) var Laser
|
|
|
|
|
|
|
|
#### MAYBE ADD A HEALTH BAR TO MAIN ITSELF ####
|
2018-05-29 00:08:30 -04:00
|
|
|
#var health = 3000
|
2018-05-27 19:22:11 -04:00
|
|
|
# DEFAULT:
|
2018-11-12 23:17:53 -05:00
|
|
|
var starting_health = 3000
|
2018-06-03 11:11:27 -04:00
|
|
|
var health = starting_health
|
2018-05-27 19:22:11 -04:00
|
|
|
|
2018-05-29 00:08:30 -04:00
|
|
|
var timer = null
|
2018-05-27 19:22:11 -04:00
|
|
|
var hit_timer = 1000
|
|
|
|
var health_multi = 1
|
|
|
|
var move_down = true
|
|
|
|
var small_move_down = true
|
|
|
|
var speed_multiplier = 3
|
|
|
|
var flashed = false
|
|
|
|
|
|
|
|
func _ready():
|
|
|
|
connect("area_entered", self, "hit")
|
2018-05-29 00:08:30 -04:00
|
|
|
timer = Timer.new()
|
|
|
|
timer.set_one_shot(false)
|
|
|
|
timer.set_wait_time(3)
|
|
|
|
timer.connect("timeout", self, "shoot")
|
|
|
|
add_child(timer)
|
|
|
|
timer.start()
|
2018-05-27 19:22:11 -04:00
|
|
|
pass
|
|
|
|
|
|
|
|
func hit(who):
|
2018-06-03 11:11:27 -04:00
|
|
|
health -= who.damage/(health_multi*3.5)
|
2018-05-27 19:22:11 -04:00
|
|
|
if health > 1500:
|
|
|
|
$Inside/InsideBadSprite.frame = 1
|
|
|
|
hit_timer = 0
|
|
|
|
else:
|
|
|
|
$Inside/InsideBadSprite.frame = 2
|
|
|
|
updateOutsideSprite()
|
|
|
|
if get_tree().is_network_server():
|
|
|
|
rpc("bossHealth", health)
|
2018-06-03 11:11:27 -04:00
|
|
|
emit_signal("boss_health", health, starting_health)
|
2018-05-27 19:22:11 -04:00
|
|
|
|
|
|
|
func _process(delta):
|
|
|
|
# Entering view
|
|
|
|
if position.x > 0:
|
2018-05-29 00:08:30 -04:00
|
|
|
position.x -= delta*((100+(position.x))/10)
|
2018-05-27 19:22:11 -04:00
|
|
|
|
2018-11-29 16:04:22 -05:00
|
|
|
wobble(delta)
|
2018-05-27 19:22:11 -04:00
|
|
|
|
2018-11-12 23:17:53 -05:00
|
|
|
if health < -1*(starting_health/10) && $Inside/InsideBadSprite.rotation_degrees < 180:
|
2018-05-29 00:08:30 -04:00
|
|
|
$Inside/InsideBadSprite.rotation_degrees += delta*20
|
|
|
|
|
|
|
|
if $Inside/InsideBadSprite.rotation_degrees > 179 && $Inside/InsideBadSprite.rotation_degrees < 190:
|
|
|
|
if position.x > 40:
|
|
|
|
$Inside/InsideBadSprite.frame = 4
|
|
|
|
position.x += delta*75
|
|
|
|
|
2018-05-27 19:22:11 -04:00
|
|
|
if health <= 0 && $BigBadSprite.position.x < 5000:
|
|
|
|
$BigBadSprite.position.x += delta*75
|
|
|
|
|
2018-05-29 00:08:30 -04:00
|
|
|
if position.x > 295 && health <= 0:
|
|
|
|
emit_signal("dead", 1000)
|
|
|
|
emit_signal("boss_fight_over")
|
|
|
|
queue_free()
|
|
|
|
|
2018-05-27 19:22:11 -04:00
|
|
|
#### SMALL WOBBLE ####
|
|
|
|
if $Inside/InsideBadSprite.position.y > 1200:
|
|
|
|
small_move_down = false
|
|
|
|
if $Inside/InsideBadSprite.position.y <= 1182:
|
|
|
|
small_move_down = true
|
|
|
|
|
|
|
|
if small_move_down:
|
|
|
|
$Inside/InsideBadSprite.position.y += delta*6
|
|
|
|
else:
|
|
|
|
$Inside/InsideBadSprite.position.y -= delta*6
|
|
|
|
|
|
|
|
#### DOES LOW HEALTH RELEASE THE INSIDE OR NO HEALTH? ####
|
|
|
|
if health <= 0 && !flashed:
|
|
|
|
emit_signal("flash")
|
2018-06-03 11:11:27 -04:00
|
|
|
$OutsideBottomCollision.disabled = true
|
|
|
|
$OutsideTopCollision.disabled = true
|
2018-05-27 19:22:11 -04:00
|
|
|
flashed = true
|
|
|
|
#queue_free()
|
|
|
|
|
|
|
|
if hit_timer < 0.15:
|
|
|
|
hit_timer += delta
|
|
|
|
elif hit_timer < 0.25:
|
|
|
|
hit_timer += delta
|
|
|
|
else:
|
|
|
|
if health > 1500:
|
|
|
|
$Inside/InsideBadSprite.frame = 0
|
|
|
|
|
|
|
|
var health_bar = Vector2(((health * 6) - 157), -273)
|
|
|
|
#$Line2D.set_point_position( 1, health_bar )
|
|
|
|
|
|
|
|
func _on_Inside_area_entered(area):
|
|
|
|
health -= 15/health_multi
|
|
|
|
updateOutsideSprite()
|
|
|
|
if health > 1500:
|
|
|
|
$Inside/InsideBadSprite.frame = 1
|
|
|
|
hit_timer = 0
|
|
|
|
else:
|
|
|
|
$Inside/InsideBadSprite.frame = 2
|
|
|
|
if get_tree().is_network_server():
|
|
|
|
rpc("bossHealth", health)
|
|
|
|
else:
|
|
|
|
pass
|
2018-06-03 11:11:27 -04:00
|
|
|
emit_signal("boss_health", health, starting_health)
|
2018-05-27 19:22:11 -04:00
|
|
|
|
|
|
|
func updateOutsideSprite():
|
2018-11-12 23:17:53 -05:00
|
|
|
if health > starting_health*.9:
|
2018-05-27 19:22:11 -04:00
|
|
|
$BigBadSprite.frame = 0
|
2018-11-12 23:17:53 -05:00
|
|
|
elif health > starting_health*.8:
|
2018-05-27 19:22:11 -04:00
|
|
|
$BigBadSprite.frame = 1
|
2018-11-12 23:17:53 -05:00
|
|
|
elif health > starting_health*.7:
|
2018-05-27 19:22:11 -04:00
|
|
|
$BigBadSprite.frame = 2
|
2018-11-12 23:17:53 -05:00
|
|
|
elif health > starting_health*.6:
|
2018-05-27 19:22:11 -04:00
|
|
|
$BigBadSprite.frame = 3
|
2018-11-12 23:17:53 -05:00
|
|
|
elif health > starting_health*.5:
|
2018-05-27 19:22:11 -04:00
|
|
|
$BigBadSprite.frame = 4
|
2018-11-12 23:17:53 -05:00
|
|
|
elif health > starting_health*.45:
|
2018-05-27 19:22:11 -04:00
|
|
|
$BigBadSprite.frame = 5
|
2018-11-12 23:17:53 -05:00
|
|
|
elif health > starting_health*.4:
|
2018-05-27 19:22:11 -04:00
|
|
|
$BigBadSprite.frame = 6
|
2018-11-12 23:17:53 -05:00
|
|
|
elif health > starting_health*.35:
|
2018-05-27 19:22:11 -04:00
|
|
|
$BigBadSprite.frame = 7
|
2018-11-12 23:17:53 -05:00
|
|
|
elif health > starting_health*.3:
|
2018-05-27 19:22:11 -04:00
|
|
|
$BigBadSprite.frame = 8
|
2018-11-12 23:17:53 -05:00
|
|
|
elif health > starting_health*.25:
|
2018-05-27 19:22:11 -04:00
|
|
|
$BigBadSprite.frame = 9
|
2018-11-12 23:17:53 -05:00
|
|
|
elif health > starting_health*.2:
|
2018-05-27 19:22:11 -04:00
|
|
|
$BigBadSprite.frame = 10
|
2018-11-12 23:17:53 -05:00
|
|
|
elif health > starting_health*.15:
|
2018-05-27 19:22:11 -04:00
|
|
|
$BigBadSprite.frame = 11
|
2018-11-12 23:17:53 -05:00
|
|
|
elif health > starting_health*.1:
|
2018-05-27 19:22:11 -04:00
|
|
|
$BigBadSprite.frame = 12
|
2018-11-12 23:17:53 -05:00
|
|
|
elif health > starting_health*.075:
|
2018-05-29 00:08:30 -04:00
|
|
|
timer.stop()
|
2018-05-27 19:22:11 -04:00
|
|
|
$BigBadSprite.frame = 13
|
|
|
|
$Inside/InsideBadSprite.frame = 2
|
|
|
|
elif health <= 0:
|
|
|
|
$BigBadSprite.frame = 14
|
2018-05-29 00:08:30 -04:00
|
|
|
|
2018-05-27 19:22:11 -04:00
|
|
|
slave func bossHealth(host_health):
|
2018-05-29 00:08:30 -04:00
|
|
|
health = host_health
|
|
|
|
|
2018-11-29 16:04:22 -05:00
|
|
|
func wobble(delta):
|
|
|
|
if position.y > 4:
|
|
|
|
move_down = false
|
|
|
|
if position.y <= -4:
|
|
|
|
move_down = true
|
|
|
|
|
|
|
|
if abs(position.y) > 4:
|
|
|
|
speed_multiplier = 1
|
|
|
|
elif abs(position.y) > 3:
|
|
|
|
speed_multiplier = 1
|
|
|
|
elif abs(position.y) > 2:
|
|
|
|
speed_multiplier = 2
|
|
|
|
elif abs(position.y) <= 2:
|
|
|
|
speed_multiplier = 3
|
|
|
|
|
|
|
|
if move_down:
|
|
|
|
if health > 1000:
|
|
|
|
position.y += delta*speed_multiplier
|
|
|
|
else:
|
|
|
|
if health > 1000:
|
|
|
|
position.y -= delta*speed_multiplier
|
|
|
|
|
2018-05-29 00:08:30 -04:00
|
|
|
var top_laser = true
|
|
|
|
func shoot():
|
|
|
|
var laser = Laser.instance()
|
|
|
|
get_node("../").add_child(laser)
|
|
|
|
laser.friendly_laser = false
|
|
|
|
laser.position.x = position.x + 720
|
|
|
|
laser.rotation_degrees = 180
|
|
|
|
if top_laser:
|
|
|
|
laser.position.y = position.y + 110
|
|
|
|
top_laser = false
|
|
|
|
else:
|
|
|
|
laser.position.y = position.y + 470
|
|
|
|
top_laser = true
|