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-- WISKER 24 25-- ================================================================================================ 26-- L O C A L V A R I A B L E S 27-- ================================================================================================ 28 29v.fireDelay = 2 30v.moveTimer = 0 31v.charge = 0 32 33local STATE_CHARGE = 1000 34local STATE_DELAY = 1001 35v.inited = false 36 37-- ================================================================================================ 38-- FUNCTIONS 39-- ================================================================================================ 40 41function init(me) 42 setupBasicEntity( 43 me, 44 "", -- texture 45 6, -- health 46 2, -- manaballamount 47 2, -- exp 48 1, -- money 49 64, -- collideRadius (for hitting entities + spells) 50 STATE_IDLE, -- initState 51 256, -- sprite width 52 256, -- sprite height 53 1, -- particle "explosion" type, maps to particleEffects.txt -1 = none 54 1, -- 0/1 hit other entities off/on (uses collideRadius) 55 3000 -- updateCull -1: disabled, default: 4000 56 ) 57 entity_scale(me, 0.75, 0.75) 58 entity_setDropChance(me, 25) 59 entity_clampToSurface(me) 60 entity_setDeathParticleEffect(me, "TinyGreenExplode") 61 entity_initSkeletal(me, "Wisker") 62 entity_setState(me, STATE_IDLE) 63 esetv(me, EV_WALLOUT, 10) 64 entity_setEatType(me, EAT_FILE, "Wisker") 65end 66 67function update(me, dt) 68 69 70 if entity_isState(me, STATE_IDLE) then 71 entity_moveAlongSurface(me, dt, 140, 6, 30) 72 entity_rotateToSurfaceNormal(me, 0.1) 73 74 -- entity_rotateToSurfaceNormal(0.1) 75 v.moveTimer = v.moveTimer + dt 76 if v.moveTimer > 4 then 77 entity_switchSurfaceDirection(me) 78 v.moveTimer = 0 79 end 80 if not(entity_hasTarget(me)) then 81 entity_findTarget(me, 1200) 82 else 83 if v.fireDelay > 0 then 84 v.fireDelay = v.fireDelay - dt 85 if v.fireDelay < 0 then 86 v.fireDelay = 3 87 entity_setState(me, STATE_CHARGE) 88 end 89 end 90 end 91 end 92 if entity_isState(me, STATE_DELAY) then 93 entity_moveAlongSurface(me, dt, 60, 6, 10) 94 entity_rotateToSurfaceNormal(me, 0.1) 95 end 96 entity_handleShotCollisions(me) 97 if entity_touchAvatarDamage(me, entity_getCollideRadius(me), 1, 500) then 98 setPoison(1, 12) 99 end 100end 101 102function enterState(me) 103 if entity_getState(me)==STATE_IDLE then 104 entity_animate(me, "waddle", -1) 105 elseif entity_isState(me, STATE_CHARGE) then 106 entity_setStateTime(me, entity_animate(me, "charge")) 107 elseif entity_isState(me, STATE_DELAY) then 108 entity_animate(me, "idle", -1) 109 entity_setStateTime(me, 1) 110 end 111end 112 113local function fireShot(me, a) 114 local s = createShot("WiskerShot", me, entity_getTarget(me)) 115 shot_setAimVector(s, entity_getAimVector(me, a, 1)) 116 shot_setOut(s, 32) 117 118end 119 120function exitState(me) 121 if entity_isState(me, STATE_CHARGE) then 122 --entity_doGlint(me, "Particles/PurpleFlare") 123 124 entity_sound(me, "SpineFire") 125 fireShot(me, -45) 126 fireShot(me, 0) 127 fireShot(me, 45) 128 129 entity_setState(me, STATE_DELAY) 130 elseif entity_isState(me, STATE_DELAY) then 131 entity_setState(me, STATE_IDLE) 132 end 133end 134 135function damage(me) 136 return true 137end 138 139function hitSurface(me) 140end 141