From 3eb5f29ab6fd3f685255c1eb71cf589cc3d0b6c9 Mon Sep 17 00:00:00 2001 From: 8bitgentleman Date: Fri, 30 Oct 2015 16:25:26 -0400 Subject: [PATCH] Hippy Grab MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The hippies “grab” the player like in the episode --- src/nodes/enemies/hippy.lua | 1 + src/nodes/enemy.lua | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/nodes/enemies/hippy.lua b/src/nodes/enemies/hippy.lua index b0b1cc74c..4f62f5da7 100644 --- a/src/nodes/enemies/hippy.lua +++ b/src/nodes/enemies/hippy.lua @@ -15,6 +15,7 @@ return { hp = 6, speed = 10, vulnerabilities = {'slash'}, + grab = true, tokens = 3, 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 }, diff --git a/src/nodes/enemy.lua b/src/nodes/enemy.lua index 0511b5ebd..6218fd24e 100644 --- a/src/nodes/enemy.lua +++ b/src/nodes/enemy.lua @@ -111,6 +111,7 @@ function Enemy.new(node, collider, enemytype) enemy.burn = false enemy.knockbackDisabled = enemy.props.knockbackDisabled or false + enemy.grab = enemy.props.grab or false enemy.fadeIn = enemy.props.fadeIn or false enemy.fade = {255, 255, 255, 0} @@ -432,8 +433,12 @@ function Enemy:collide(node, dt, mtv_x, mtv_y) player:hurt(self.props.damage) player.top_bb:move(mtv_x, mtv_y) player.bottom_bb:move(mtv_x, mtv_y) - player.velocity.y = -450 - player.velocity.x = self.player_rebound * ( player.position.x < self.position.x + ( self.props.width / 2 ) + self.bb_offset.x and -1 or 1 ) + if self.grab then + player.freeze = true + else + player.velocity.y = -450 + player.velocity.x = self.player_rebound * ( player.position.x < self.position.x + ( self.props.width / 2 ) + self.bb_offset.x and -1 or 1 ) + end end end @@ -441,6 +446,7 @@ function Enemy:collide_end( node ) if node and node.isPlayer and node.current_enemy == self then node.current_enemy = nil end + player.freeze = false end function Enemy:update( dt, player, map )