Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Enemy = require 'nodes/enemy'
- local gamestate = require 'vendor/gamestate'
- local sound = require 'vendor/TEsound'
- local Timer = require 'vendor/timer'
- local Fireball = require 'nodes/fire_cornelius_big'
- local utils = require 'utils'
- local Dialog = require 'dialog'
- local anim8 = require 'vendor/anim8'
- local window = require 'window'
- local camera = require 'camera'
- local fonts = require 'fonts'
- local cheat = require 'cheat'
- local Sprite = require 'nodes/sprite'
- return {
- name = 'cornelius',
- attackDelay = 1,
- height = 192,
- width = 144,
- damage = 30,
- special_damage = {cornelius = 5000},
- --attack_bb = true,
- jumpkill = false,
- knockback = 0,
- player_rebound = 400,
- antigravity = true,
- bb_width = 124,
- bb_height = 182,
- bb_offset = { x = 0, y = -5},
- attack_width = 40,
- velocity = {x = 0, y = 10},
- hp = 100,
- tokens = 100,
- dyingdelay = 2,
- fadeIn = true,
- enterScript ={
- "{{grey}}Welcome{{white}}, you are the first to make it to the {{orange}}Throne of Hawkthorne{{white}}.",
- "Let me take a look at you...",
- "According to your {{olive}}complexion{{white}}, I think you might be...{{purple}}" .. player.character.name .. "{{white}}.",
- "You don't deserve my fortune!",
- },
- deathScript ={
- "{{grey}}*heavy breathing*{{white}} I suppose you're wondering,{{purple}} player{{white}}. ",
- "Why record myself breathing weird and letting you destroy me?",
- "Because I am a man of {{red}}Honor!{{white}}",
- "So you've earned the pleasure of my death!",
- },
- tokenTypes = { -- p is probability ceiling and this list should be sorted by it, with the last being 1
- { item = 'coin', v = 1, p = 0.9 },
- { item = 'health', v = 1, p = 1 }
- },
- animations = {
- default = {
- right = {'loop', {'1,1'}, 0.25},
- left = {'loop', {'1,1'}, 0.25}
- },
- talking = {
- right = {'loop', {'1-3,1','2,1'}, 0.15},
- left = {'loop', {'1-3,1','2,1'}, 0.15}
- },
- attack = {
- right = {'loop', {'1-3,2','2,2'}, 0.1},
- left = {'loop', {'1-3,2','2,2'}, 0.1}
- },
- hurt = {
- right = {'loop', {'1-3,2','2,2'}, 0.1},
- left = {'loop', {'1-3,2','2,2'}, 0.1}
- },
- dying = {
- right = {'loop', {'1-3,1','2,1'}, 0.15},
- left = {'loop', {'1-3,1','2,1'}, 0.15}
- },
- enter = {
- right = {'once', {'1,1'}, 0.2},
- left = {'once', {'1,1'}, 0.2}
- },
- teleport = {
- right = {'loop', {'1-3,3','2,3'}, 0.1},
- left = {'loop', {'1-3,3','2,3'}, 0.1}
- },
- },
- enter = function( enemy )
- enemy.direction = math.random(2) == 1 and 'left' or 'right'
- enemy.directionY = math.random(2) == 1 and 'up' or 'down'
- enemy.state = 'attack'
- enemy.maxy = enemy.position.y + 10
- enemy.miny = enemy.position.y - 10
- enemy.hatched = false
- enemy.last_teleport = 0
- enemy.last_attack = 0
- enemy.last_fireball = 0
- enemy.swoop_speed = 150
- enemy.fly_speed = 75
- enemy.swoop_distance = 150
- enemy.swoop_ratio = 0.25
- sound.playMusic("cornelius-attacks")
- --enemy.velocity.x = 100
- cheat:fairfight()
- --remove this after testing
- --enemy.rage = true
- --sparkles
- enemy.props.sparkleRotated( enemy, 45, 0 )
- enemy.props.sparkleRotated( enemy, 50, 60 )
- enemy.props.sparkleRotated( enemy, 110, 150 )
- Timer.add(.2, function()
- enemy.props.sparkle( enemy, 0, 100 )
- enemy.props.sparkleRotated( enemy, 120, 100 )
- Timer.add(.2, function()
- enemy.props.sparkleRotated( enemy, 70, 140 )
- enemy.props.sparkle( enemy, 0, 0 )
- Timer.add(.2, function()
- enemy.props.sparkleRotated( enemy, 45, 0 )
- enemy.props.sparkleRotated( enemy, 50, 60 )
- enemy.props.sparkleRotated( enemy, 110, 150 )
- end)
- end)
- end)
- --enter dialog
- if enemy.enterScript then
- enemy.state = 'talking'
- Dialog.new(enemy.enterScript, function()
- enemy.hatched = true
- enemy.state = 'attack'
- enemy.rage = true
- end, nil, 'small')
- end
- end,
- sparkleRotated = function(enemy, offsetX, offestY)
- local node = {
- type = 'sprite',
- name = 'sparkle_rotated',
- x = enemy.position.x+offsetX,
- y = enemy.position.y+offestY,
- width = 45,
- height = 45,
- properties = {sheet = 'images/sprites/castle/cornelius_sparkles_big_rotated.png',
- speed = .2,
- animation = '1-4,1',
- width = 45,
- height = 45,
- mode = 'once',
- foreground = true}
- }
- local sparkleR = Sprite.new( node, enemy.collider )
- local level = enemy.containerLevel
- level:addNode(sparkleR)
- end,
- sparkle = function(enemy, offsetX, offestY)
- local node = {
- type = 'sprite',
- name = 'sparkle',
- x = enemy.position.x+offsetX,
- y = enemy.position.y+offestY,
- width = 45,
- height = 45,
- properties = {sheet = 'images/sprites/castle/cornelius_sparkles_big.png',
- speed = .2,
- animation = '1-4,1',
- width = 45,
- height = 45,
- mode = 'once',
- foreground = true}
- }
- local sparkle = Sprite.new( node, enemy.collider )
- local level = enemy.containerLevel
- level:addNode(sparkle)
- end,
- fireball = function( enemy, player )
- enemy.last_fireball = 0
- enemy.last_attack = 0
- local Fireball = require('nodes/fire_cornelius_big')
- local node = {
- type = 'fire_cornelius_big',
- name = 'fireball',
- x = player.position.x,
- y = enemy.position.y,
- width = 34,
- height = 110,
- properties = {}
- }
- local fireball = Fireball.new( node, enemy.collider )
- local level = enemy.containerLevel
- level:addNode(fireball)
- end,
- teleport = function ( enemy, player, dt )
- enemy.state = 'teleport'
- enemy.last_teleport = 0
- enemy.last_attack = 0
- sound.playSfx("teleport")
- Timer.add(.5, function()
- if enemy.position.x >= player.position.x then
- enemy.position.x = player.position.x - (math.abs((enemy.position.x+(enemy.width/2))-player.position.x))
- enemy.state = 'attack'
- elseif enemy.position.x <= player.position.x then
- enemy.position.x = player.position.x - (math.abs((enemy.position.x+(enemy.width/2))-player.position.x))
- enemy.state = 'attack'
- end
- end)
- end,
- -- adjusts values needed to initialize swooping
- targetDive = function ( enemy, player, direction )
- enemy.fly_dir = direction
- enemy.launch_y = enemy.position.y
- local p_x = player.position.x - player.character.bbox.x
- local p_y = player.position.y - player.character.bbox.y
- enemy.swoop_distance = math.abs(p_y - enemy.position.y)
- enemy.swoop_ratio = math.abs(p_x - enemy.position.x) / enemy.swoop_distance
- -- experimentally determined max and min swoop_ratio values
- enemy.swoop_ratio = math.min(1.4, math.max(0.7, enemy.swoop_ratio))
- end,
- startDive = function ( enemy )
- enemy.last_attack = 0
- enemy.last_teleport = 0
- enemy.velocity.y = enemy.swoop_speed
- -- swoop ratio used to center bat on target
- enemy.velocity.x = -( enemy.swoop_speed * enemy.swoop_ratio ) * enemy.fly_dir
- Timer.add(.5, function()
- enemy.velocity.y = -enemy.fly_speed
- enemy.velocity.x = -(enemy.swoop_speed / 1.5) * enemy.fly_dir
- print('undive')
- end)
- end,
- -- Compares vulnerabilities to a weapons special damage and sums up total damage
- calculateDamage = function(self, damage, special_damage)
- if not special_damage then
- if self.state =='teleport' then
- print('double damage')
- damage = 2*damage
- return damage
- else
- print('regular damage')
- return damage
- end
- end
- for _, value in ipairs(self.vulnerabilities) do
- if special_damage[value] ~= nil then
- if enemy.state =='teleport' then
- damage = (damage + special_damage[value])*2
- print('double damage')
- else
- damage = damage + special_damage[value]
- print('regular damage')
- end
- end
- end
- return damage
- end,
- die = function( enemy )
- sound.playMusic("cornelius-forfeiting")
- Dialog.new(enemy.deathScript, function()
- enemy:die()
- sound.playSfx("cornelius-ending")
- sound.stopMusic()
- local NodeClass = require('nodes/key')
- local node = {
- type = 'key',
- name = 'greendale',
- x = enemy.position.x + enemy.width / 2 ,
- y = enemy.position.y + enemy.height+48,
- width = 24,
- height = 24,
- properties = {info = "Congratulations. You have found the {{green_dark}}Greendale{{white}} key. If you want more to explore, you now have access to the {{green_dark}}Greendale{{white}} campus!",
- 'To get there, exit the study room then use the door to the left. Remember to bring the key!',
- },
- }
- local spawnedNode = NodeClass.new(node, enemy.collider)
- local level = gamestate.currentState()
- level:addNode(spawnedNode)
- end, nil, 'small')
- end,
- draw = function( enemy )
- fonts.set( 'small' )
- --love.graphics.setStencil( )
- local energy = love.graphics.newImage('images/enemies/bossHud/energy.png')
- local bossChevron = love.graphics.newImage('images/enemies/bossHud/bossChevron.png')
- local bossPic = love.graphics.newImage('images/enemies/bossHud/cornelius.png')
- energy:setFilter('nearest', 'nearest')
- bossChevron:setFilter('nearest', 'nearest')
- bossPic:setFilter('nearest', 'nearest')
- x, y = camera.x + window.width - 130 , camera.y + 10
- end,
- update = function( dt, enemy, player, level )
- if enemy.dead then return end
- local direction = player.position.x > enemy.position.x + 70 and -1 or 1
- local offset = math.random(0,200)
- if enemy.state == 'default' and not enemy.hatched then
- --enemy.velocity.y = -25
- --enemy.velocity.x = 100
- elseif enemy.hatched then
- --[[if enemy.position.x > player.position.x then
- enemy.velocity.x = -enemy.velocity.x
- elseif enemy.position.x < player.position.x then
- enemy.velocity.x = -enemy.velocity.x
- end
- if enemy.position.y <= enemy.miny then
- enemy.velocity.y = -enemy.velocity.y
- elseif enemy.position.y >= enemy.maxy then
- enemy.velocity.y = -enemy.velocity.y
- end]]
- enemy.rage = true
- enemy.glow = true
- enemy.lightning = true
- --enemy.props.fire(enemy)
- enemy.last_teleport = enemy.last_teleport + dt
- enemy.last_attack = enemy.last_attack + dt
- enemy.last_fireball = enemy.last_fireball + dt
- enemy.props.targetDive( enemy, player, -direction )
- if enemy.last_attack > 2 and enemy.last_teleport > 3 then
- enemy.props.fireball( enemy, player )
- --enemy.props.teleport( enemy, player, dt )
- --enemy.props.startDive ( enemy )
- end
- end
- end
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement