1-- Copyright (C) 2007, 2010 - Bit-Blot 2-- 3-- This file is part of Aquaria. 4-- 5-- Aquaria is free software; you can redistribute it and/or 6-- modify it under the terms of the GNU General Public License 7-- as published by the Free Software Foundation; either version 2 8-- of the License, or (at your option) any later version. 9-- 10-- This program is distributed in the hope that it will be useful, 11-- but WITHOUT ANY WARRANTY; without even the implied warranty of 12-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13-- 14-- See the GNU General Public License for more details. 15-- 16-- You should have received a copy of the GNU General Public License 17-- along with this program; if not, write to the Free Software 18-- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 20if not v then v = {} end 21if not AQUARIA_VERSION then dofile("scripts/entities/entityinclude.lua") end 22 23v.n = 0 24v.glow = 0 25v.boneGlow = 0 26v.lungeDelay = 0 27 28local STATE_AROUSED = 1001 29local STATE_LUNGE = 1002 30v.hitDelay = 0 31v.lunging = false 32 33function init(me) 34 v.glow = createQuad("Naija/LightFormGlow", 13) 35 quad_scale(v.glow, 3, 3, 1) 36 quad_alpha(v.glow, 1) 37 38 setupEntity(me) 39 entity_setEntityType(me, ET_ENEMY) 40 entity_initSkeletal(me, "AnglerFish") 41 --entity_setAllDamageTargets(me, false) 42 43 entity_generateCollisionMask(me) 44 45 v.boneGlow = entity_getBoneByName(me, "Glow") 46 47 entity_setCullRadius(me, 30000) 48 49 entity_setState(me, STATE_IDLE) 50 51 --[[ 52 entity_setDamageTarget(me, DT_AVATAR_ENERGYBLAST, true) 53 entity_setDamageTarget(me, DT_AVATAR_SHOCK, true) 54 55 entity_setDamageTarget(me, DT_AVATAR_VINE, true) 56 ]]-- 57 58 59 60 entity_setMaxSpeed(me, 600) 61 entity_setEntityLayer(me, 1) 62 entity_setCollideRadius(me, 128) 63 entity_setBounceType(me, BOUNCE_REAL) 64 entity_setBounce(me, 0.5) 65 66 entity_setDeathScene(me, true) 67 68 entity_setHealth(me, 32) 69 70 entity_setDropChance(me, 20, 1) 71 72 entity_setUpdateCull(me, 3000) 73 74 entity_setNaijaReaction(me, "shock") 75 76 --entity_setDeathParticleEffect(me, "BigFishDie") 77 78 loadSound("AnglerAwake") 79 loadSound("AnglerDie") 80 loadSound("AnglerHit") 81end 82 83function dieNormal(me) 84 if chance(5) then 85 spawnIngredient("GlowingEgg", entity_x(me), entity_y(me)) 86 end 87end 88 89function postInit(me) 90 v.n = getNaija() 91 entity_setTarget(me, v.n) 92end 93 94function update(me, dt) 95 if v.hitDelay > 0 then 96 v.hitDelay = v.hitDelay - dt 97 if v.hitDelay < 0 then 98 v.hitDelay = 0 99 end 100 end 101 102 if entity_isState(me, STATE_AROUSED) then 103 104 if entity_isTargetInRange(me, 256) then 105 entity_moveTowardsTarget(me, dt, -1000) 106 else 107 entity_moveTowardsTarget(me, dt, 600) 108 end 109 entity_doCollisionAvoidance(me, dt, 12, 0.5) 110 if not entity_isEntityInRange(me, v.n, 1200) then 111 entity_clearVel(me) 112 entity_setState(me, STATE_IDLE) 113 else 114 v.lungeDelay = v.lungeDelay + dt 115 if v.lungeDelay > 3 then 116 v.lungeDelay = 0 117 entity_setState(me, STATE_LUNGE) 118 end 119 end 120 end 121 if entity_isState(me, STATE_AROUSED) or entity_isState(me, STATE_LUNGE) then 122 entity_doCollisionAvoidance(me, dt, 4, 1.0) 123 entity_updateMovement(me, dt) 124 125 end 126 if entity_isState(me, STATE_LUNGE) then 127 if not v.lunging then 128 entity_doFriction(me, dt, 1000) 129 else 130 entity_moveTowardsTarget(me, dt, 500) 131 end 132 133 --[[ 134 local e = getFirstEntity() 135 while e ~= 0 do 136 if e~=me and not entity_isDead(e) and entity_getEntityType(e) == ET_ENEMY and entity_isDamageTarget(e, DT_AVATAR_BITE) then 137 if entity_isEntityInRange(me, e, 96) then 138 entity_damage(e, me, 2) 139 end 140 end 141 e = getNextEntity() 142 end 143 ]]-- 144 end 145 local gx, gy = bone_getWorldPosition(v.boneGlow) 146 quad_setPosition(v.glow, gx, gy, 0.1) 147 if entity_isState(me, STATE_IDLE) then 148 if entity_isPositionInRange(v.n, gx, gy, 200) then 149 entity_sound(me, "AnglerAwake", 950 + math.random(100)) 150 entity_setState(me, STATE_LUNGE) 151 152 end 153 end 154 if math.abs(entity_x(me)-entity_x(v.n)) > 300 then 155 entity_flipToEntity(me, v.n) 156 end 157 158 entity_handleShotCollisionsSkeletal(me) 159 local bone = entity_collideSkeletalVsCircle(me, v.n) 160 if bone ~=0 then 161 if entity_isState(me, STATE_IDLE) then 162 entity_setState(me, STATE_AROUSED) 163 end 164 if avatar_isTouchHit() then 165 entity_damage(v.n, me, 1) 166 end 167 entity_pushTarget(me, 500) 168 end 169end 170 171function enterState(me) 172 if entity_isState(me, STATE_IDLE) then 173 entity_animate(me, "idle", -1) 174 if v.glow ~= 0 then 175 quad_scale(v.glow, 3, 3, 1) 176 quad_alpha(v.glow, 1) 177 end 178 elseif entity_isState(me, STATE_AROUSED) then 179 entity_setDamageTarget(me, DT_AVATAR_LIZAP, true) 180 entity_animate(me, "aroused", -1) 181 quad_scale(v.glow, 9, 9, 0.8) 182 elseif entity_isState(me, STATE_LUNGE) then 183 entity_setDamageTarget(me, DT_AVATAR_LIZAP, true) 184 v.lunging = false 185 quad_scale(v.glow, 6, 6, 0.8) 186 entity_sound(me, "AnglerAwake", 1000 + math.random(100)) 187 entity_setStateTime(me, entity_animate(me, "lunge")) 188 --entity_rotateToEntity(me, v.n) 189 elseif entity_isState(me, STATE_DEATHSCENE) then 190 shakeCamera(2, 2) 191 playSfx("AnglerDie") 192 spawnParticleEffect("BigFishDie", entity_getPosition(me)) 193 entity_setStateTime(me, entity_animate(me, "die")-0.1) 194 elseif entity_isState(me, STATE_DEAD) then 195 spawnParticleEffect("BigFishDie", entity_getPosition(me)) 196 spawnParticleEffect("TinyRedExplode", entity_getPosition(me)) 197 quad_delete(v.glow, 3) 198 end 199end 200 201function exitState(me) 202 if entity_isState(me, STATE_LUNGE) then 203 entity_setMaxSpeedLerp(me, 0.5) 204 entity_setMaxSpeedLerp(me, 1, 1) 205 entity_setState(me, STATE_AROUSED) 206 end 207end 208 209function damage(me, attacker, bone, damageType, dmg) 210 if entity_isState(me, STATE_IDLE) then 211 entity_setState(me, STATE_AROUSED, -1, 1) 212 end 213 if entity_isState(me, STATE_AROUSED) then 214 v.lungeDelay = v.lungeDelay - 0.1 215 end 216 --entity_sound(me, "AnglerHit", 1000 + math.random(100)) 217 return true 218end 219 220function animationKey(me, key) 221 if entity_isState(me, STATE_LUNGE) then 222 if key == 2 then 223 v.lunging = true 224 entity_setMaxSpeedLerp(me, 2.0) 225 entity_setMaxSpeedLerp(me, 1, 2) 226 entity_moveTowardsTarget(me, 1, 8000) 227 entity_flipToEntity(me, v.n) 228 --[[ 229 if entity_isfh(me) then 230 entity_rotateToVel(me, 0.1, -90) 231 else 232 entity_rotateToVel(me, 0.1, 90) 233 end 234 ]]-- 235 elseif key == 3 then 236 237 entity_sound(me, "Bite", 700 + math.random(100)) 238 entity_moveTowardsTarget(me, 1, 8000) 239 end 240 end 241end 242 243function hitSurface(me) 244 if entity_isState(me, STATE_LUNGE) then 245 if v.hitDelay == 0 then 246 entity_sound(me, "BigRockHit", 900+math.random(200)) 247 local cx, cy = getLastCollidePosition() 248 spawnParticleEffect("Dirt", cx, cy) 249 shakeCamera(5, 0.5) 250 v.hitDelay = 0.8 251 end 252 end 253end 254 255function songNote(me, note) 256end 257 258function songNoteDone(me, note) 259end 260 261function song(me, song) 262end 263 264function activate(me) 265end 266 267