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 23-- ================================================================================================ 24-- Q U E E N H Y D R A 25-- ================================================================================================ 26 27 28-- ================================================================================================ 29-- L O C A L V A R I A B L E S 30-- ================================================================================================ 31 32 chaseDelay = 0 33 34-- ================================================================================================ 35-- FUNCTIONS 36-- ================================================================================================ 37 38function init() 39 setupBasicEntity( 40 "wurm-head", -- texture 41 15, -- health 42 1, -- manaballamount 43 2, -- exp 44 1, -- money 45 32, -- collideRadius (only used if hit entities is on) 46 STATE_IDLE, -- initState 47 256, -- sprite width 48 256, -- sprite height 49 0, -- particle "explosion" type, maps to particleEffects.txt -1 = none 50 0, -- 0/1 hit other entities off/on (uses collideRadius) 51 5000 -- updateCull -1: disabled, default: 4000 52 ) 53 54 entity_flipVertical() -- fix the head orientation 55 56 if getFlag("Q1")==1 then 57 entity_delete() 58 else 59 entity_initSegments( 60 8, -- num segments 61 2, -- minDist 62 26, -- maxDist 63 "wurm-body", -- body tex 64 "wurm-tail", -- tail tex 65 256, -- width 66 256, -- height 67 0.05, -- taper 68 0 -- reverse segment direction 69 ) 70 end 71 72 73end 74 75function update(dt) 76 if entity_hasTarget() then 77 if entity_isTargetInRange(64) then 78 entity_hurtTarget(1); 79 entity_pushTarget(400); 80 end 81 end 82 if chaseDelay > 0 then 83 chaseDelay = chaseDelay - dt 84 if chaseDelay < 0 then 85 chaseDelay = 0 86 end 87 end 88 if entity_getState()==STATE_IDLE then 89 if not entity_hasTarget() then 90 entity_findTarget(800) 91 else 92 if chaseDelay==0 then 93 if entity_isTargetInRange(1000) then 94 if entity_getHealth() < 4 then 95 entity_setMaxSpeed(600) 96 entity_moveTowardsTarget(dt, 1500) 97 else 98 entity_setMaxSpeed(400) 99 entity_moveTowardsTarget(dt, 1000) 100 end 101 else 102 entity_setMaxSpeed(100) 103 end 104 end 105 end 106 end 107 entity_doEntityAvoidance(dt, 200, 0.1) 108 if entity_getHealth() < 4 then 109 entity_doSpellAvoidance(dt, 64, 0.5); 110 end 111 entity_doCollisionAvoidance(dt, 5, 1) 112 entity_updateMovement(dt) 113 entity_rotateToVel(0.1) 114end 115 116function enterState() 117 if entity_getState()==STATE_IDLE then 118 elseif entity_getState()==STATE_DEAD then 119 conversation("Q1-BossDead") 120 setFlag("TransitActive", 1) 121 setFlag("Q1", 1) 122 end 123end 124 125function exitState() 126end 127 128function hitSurface() 129end 130