diff --git a/source/platform/pcart.cpp b/source/platform/pcart.cpp index b17057f0b..c45bee9fa 100644 --- a/source/platform/pcart.cpp +++ b/source/platform/pcart.cpp @@ -94,6 +94,7 @@ void CNpcCartPlatform::processMovement( int _frames ) // have touched down m_inJump = false; + moveY += groundHeight; } } else @@ -238,3 +239,67 @@ void CNpcCartPlatform::jump() m_vertSpeed = -6 << 8; } } + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void CNpcCartPlatform::collidedWith( CThing *_thisThing ) +{ + switch(_thisThing->getThingType()) + { + case TYPE_PLAYER: + { + CPlayer *player; + DVECTOR playerPos; + CRECT collisionArea; + + // Only interested in SBs feet colliding with the box (pkg) + player=(CPlayer*)_thisThing; + playerPos=player->getPos(); + collisionArea=getCollisionArea(); + + s32 threshold = abs( collisionArea.y2 - collisionArea.y1 ); + + if ( threshold > 16 ) + { + threshold = 16; + } + + if( playerPos.vx >= collisionArea.x1 && playerPos.vx <= collisionArea.x2 ) + { + if ( checkCollisionDelta( _thisThing, threshold, collisionArea ) ) + { + player->setPlatform( this ); + + m_contact = true; + } + else + { + if( playerPos.vy >= collisionArea.y1 && playerPos.vy <= collisionArea.y2 ) + { + if ( m_isActivated || player->getPosDelta().vy >= 0 ) + { + int height = getHeightFromPlatformAtPosition( playerPos.vx, playerPos.vy ); + + if ( height >= -threshold && height < 1 ) + { + player->setPlatform( this ); + + m_contact = true; + } + } + } + } + } + + break; + } + + case TYPE_NPC: + case TYPE_HAZARD: + break; + + default: + ASSERT(0); + break; + } +} diff --git a/source/platform/pcart.h b/source/platform/pcart.h index 8ee6ca1ab..ed2822fe3 100644 --- a/source/platform/pcart.h +++ b/source/platform/pcart.h @@ -27,6 +27,7 @@ public: virtual void jump(); protected: virtual void processMovement( int _frames ); + virtual void collidedWith(CThing *_thisThing); s32 m_carSpeed; u8 m_isActivated; diff --git a/source/platform/plurve.cpp b/source/platform/plurve.cpp index 503db7602..6172cb053 100644 --- a/source/platform/plurve.cpp +++ b/source/platform/plurve.cpp @@ -18,10 +18,11 @@ void CNpcLoveBoatPlatform::postInit() { - CNpcRaftPlatform::postInit(); + CNpcCartPlatform::postInit(); sBBox boundingBox = m_modelGfx->GetBBox(); boundingBox.YMin += 32; setCollisionSize( ( boundingBox.XMax - boundingBox.XMin ), ( boundingBox.YMax - boundingBox.YMin ) ); setCollisionCentreOffset( ( boundingBox.XMax + boundingBox.XMin ) >> 1, ( boundingBox.YMax + boundingBox.YMin ) >> 1 ); + calculateNonRotatedCollisionData(); } diff --git a/source/platform/plurve.h b/source/platform/plurve.h index 7a01d7c43..df20cec7f 100644 --- a/source/platform/plurve.h +++ b/source/platform/plurve.h @@ -14,11 +14,11 @@ #ifndef __PLATFORM_PLURVE_H__ #define __PLATFORM_PLURVE_H__ -#ifndef __PLATFORM_PRAFT_H__ -#include "platform\praft.h" +#ifndef __PLATFORM_PCART_H__ +#include "platform\pcart.h" #endif -class CNpcLoveBoatPlatform : public CNpcRaftPlatform +class CNpcLoveBoatPlatform : public CNpcCartPlatform { public: virtual void postInit();