diff --git a/source/enemy/nscrab.cpp b/source/enemy/nscrab.cpp index 350963efd..f741319fc 100644 --- a/source/enemy/nscrab.cpp +++ b/source/enemy/nscrab.cpp @@ -87,6 +87,11 @@ bool CNpcSpiderCrabEnemy::processSensor() m_attackDist = abs( playerXDist ); + if ( abs( m_attackDist ) < 1 ) + { + m_attackDist = 1; + } + m_controlFunc = NPC_CONTROL_CLOSE; m_extension = 0; m_velocity = 5; diff --git a/source/platform/pjellfsh.cpp b/source/platform/pjellfsh.cpp index 3213f4442..a15b9bd98 100644 --- a/source/platform/pjellfsh.cpp +++ b/source/platform/pjellfsh.cpp @@ -27,6 +27,161 @@ #include "utils\utils.h" #endif +#ifndef __GAME_GAME_H__ +#include "game\game.h" +#endif + + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +void CNpcJellyfishPlatform::postInit() +{ + CNpcLinearPlatform::postInit(); + + m_vertScale = 0; + m_dipCount = 0; +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void CNpcJellyfishPlatform::collidedWith( CThing *_thisThing ) +{ + switch(_thisThing->getThingType()) + { + case TYPE_PLAYER: + { + if ( m_detectCollision && m_isActive ) + { + CPlayer *player; + DVECTOR playerPos; + CRECT collisionArea; + CRECT playerArea; + + // Only interested in SBs feet colliding with the box (pkg) + player=(CPlayer*)_thisThing; + playerPos=player->getPos(); + playerArea=player->getCollisionArea(); + collisionArea=getCollisionArea(); + + s32 height = getHeightFromPlatformAtPosition(playerPos.vx,playerPos.vy); + + if(playerPos.vx>=collisionArea.x1&&playerPos.vx<=collisionArea.x2&& + playerPos.vy>=collisionArea.y1&&playerPos.vy<=collisionArea.y2) + //if(((playerArea.x1>=collisionArea.x1&&playerArea.x1<=collisionArea.x2)||(playerArea.x2>=collisionArea.x1&&playerArea.x2<=collisionArea.x2)||(playerArea.x1<=collisionArea.x1&&playerArea.x2>=collisionArea.x2))&& + //((playerArea.y1>=thatRect.y1&&playerArea.y1<=thatRect.y2)||(playerArea.y2>=thatRect.y1&&playerArea.y2<=thatRect.y2)||(playerArea.y1<=thatRect.y1&&playerArea.y2>=thatRect.y2))) + { + player->setPlatform( this ); + + if( height == 0 ) + { + m_contact = true; + } + } + + if ( height < -30 ) + { + // shock player + + player->takeDamage( DAMAGE__SHOCK_ENEMY, REACT__GET_DIRECTION_FROM_THING, _thisThing ); + } + } + + break; + } + + default: + break; + } +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void CNpcJellyfishPlatform::think( int _frames ) +{ + /*if ( m_contact ) + { + if ( m_vertScale > -2048 ) + { + m_vertScale -= 10; + } + + Pos.vy += 3; + } + else if ( m_vertScale < 0 ) + { + m_vertScale += 10; + }*/ + + if ( m_contact ) + { + if ( m_dipCount < GameState::getOneSecondInFrames() ) + { + s16 sineVal = ( m_dipCount << 10 ) / GameState::getOneSecondInFrames(); + + Pos.vy += ( 3 * rcos( sineVal ) ) >> 12; + + m_dipCount += _frames; + } + } + else + { + m_dipCount = 0; + } + + CNpcLinearPlatform::think( _frames ); +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void CNpcJellyfishPlatform::render() +{ + if ( m_isActive ) + { + CPlatformThing::render(); + + if (canRender()) + { + DVECTOR &renderPos=getRenderPos(); + SVECTOR rotation; + rotation.vx = 0; + rotation.vy = 0; + rotation.vz = 0; + + VECTOR scale; + scale.vx = ONE; + //scale.vy = ONE + m_vertScale; + scale.vy = ONE; + scale.vz = ONE; + + m_modelGfx->Render(renderPos,&rotation,&scale); + +#if defined (__USER_paul__) || defined (__USER_charles__) + DVECTOR offset = CLevel::getCameraPos(); + DVECTOR centre; + DVECTOR size; + int halfLength; + int x1,y1,x2,y2; + + centre=getCollisionCentre(); + size=getCollisionSize(); + halfLength=size.vx>>1; + + x1=-halfLength*mcos(getCollisionAngle()&4095)>>12; + y1=-halfLength*msin(getCollisionAngle()&4095)>>12; + x2=+halfLength*mcos(getCollisionAngle()&4095)>>12; + y2=+halfLength*msin(getCollisionAngle()&4095)>>12; + + centre.vx-=offset.vx; + centre.vy-=offset.vy; + x1+=centre.vx; + y1+=centre.vy; + x2+=centre.vx; + y2+=centre.vy; + + DrawLine(x1,y1,x2,y2,0,255,0,0); +#endif + } + + } +} \ No newline at end of file diff --git a/source/platform/pjellfsh.h b/source/platform/pjellfsh.h index 09c32a609..2473fcd11 100644 --- a/source/platform/pjellfsh.h +++ b/source/platform/pjellfsh.h @@ -14,14 +14,21 @@ #ifndef __PLATFORM_PJELLFSH_H__ #define __PLATFORM_PLANTERN_H__ -#ifndef __PLATFORM_PLATFORM_H__ -#include "platform\platform.h" +#ifndef __PLATFORM_PLINEAR_H__ +#include "platform\plinear.h" #endif -class CNpcJellyfishPlatform : public CNpcPlatform +class CNpcJellyfishPlatform : public CNpcLinearPlatform { public: - + virtual void render(); + virtual void postInit(); + virtual void think( int _frames ); +protected: + virtual void collidedWith(CThing *_thisThing); + + s32 m_vertScale; + u8 m_dipCount; }; #endif \ No newline at end of file diff --git a/source/platform/platdata.cpp b/source/platform/platdata.cpp index f3cae873a..7b360653b 100644 --- a/source/platform/platdata.cpp +++ b/source/platform/platdata.cpp @@ -399,5 +399,6 @@ CNpcPlatform::NPC_PLATFORM_UNIT_TYPE CNpcPlatform::mapEditConvertTable[NPC_PLATF NPC_BUBBLE_GEYSER_GENERATOR, NPC_BIG_WHEEL_PLATFORM, NPC_STEERABLE_BARREL_PLATFORM, + NPC_JELLYFISH_PLATFORM, NPC_PLAYER_BUBBLE_PLATFORM, }; diff --git a/source/platform/platform.cpp b/source/platform/platform.cpp index 03e6a4dd8..1ebbf52f6 100644 --- a/source/platform/platform.cpp +++ b/source/platform/platform.cpp @@ -139,6 +139,10 @@ #include "platform\psbarrel.h" #endif +#ifndef __PLATFORM_PJELLFSH_H__ +#include "platform\pjellfsh.h" +#endif + #include "fx\fx.h" #include "fx\fxjfish.h" @@ -324,6 +328,12 @@ CNpcPlatform *CNpcPlatform::Create(sThingPlatform *ThisPlatform) break; } + case NPC_JELLYFISH_PLATFORM: + { + platform = new ("jellyfish platform") CNpcJellyfishPlatform; + break; + } + default: { ASSERT( 0 ); @@ -482,7 +492,7 @@ void CNpcPlatform::postInit() setCollisionSize( ( boundingBox.XMax - boundingBox.XMin ), PLATFORMCOLLISIONHEIGHT); setCollisionCentreOffset( ( boundingBox.XMax + boundingBox.XMin ) >> 1, boundingBox.YMin ); - if ( m_type == NPC_LINEAR_PLATFORM ) + /*if ( m_type == NPC_LINEAR_PLATFORM ) { switch( CLevel::getCurrentChapter() ) { @@ -509,7 +519,7 @@ void CNpcPlatform::postInit() // CFXJellyFishLegs *T=(CFXJellyFishLegs*)CFX::Create(CFX::FX_TYPE_JELLYFISH_LEGS,this); // T->SetUp(64,4,8,8); - } + }*/ } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/tools/Data/bin/MkLevel.ini b/tools/Data/bin/MkLevel.ini index d4a933518..2ed992f95 100644 --- a/tools/Data/bin/MkLevel.ini +++ b/tools/Data/bin/MkLevel.ini @@ -79,7 +79,7 @@ Jelly_Launcher=16 # Platforms [PLATFORM] Bubble=4 -Jellyfish=1 +Jellyfish=25 Industrial=1 Leaf=2 FishHook1=5