diff --git a/source/platform/pbounce.cpp b/source/platform/pbounce.cpp index 45ac71109..8c1ef8967 100644 --- a/source/platform/pbounce.cpp +++ b/source/platform/pbounce.cpp @@ -128,11 +128,13 @@ void CNpcBouncePlatform::render() #if defined (__USER_paul__) || defined (__USER_charles__) DVECTOR centre; + DVECTOR size; int halfLength; int x1,y1,x2,y2; centre=getCollisionCentre(); - halfLength=PLATFORMWIDTH/2; + size=getCollisionSize(); + halfLength=size.vx>>1; x1=-halfLength*mcos(getCollisionAngle()&4095)>>12; y1=-halfLength*msin(getCollisionAngle()&4095)>>12; diff --git a/source/platform/pbranch.cpp b/source/platform/pbranch.cpp index 9b71caa46..a8a2648a0 100644 --- a/source/platform/pbranch.cpp +++ b/source/platform/pbranch.cpp @@ -37,6 +37,7 @@ void CNpcBranchPlatform::postInit() { m_angularVelocity = 0; + m_platformWidth <<= 1; } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -81,6 +82,48 @@ void CNpcBranchPlatform::setWaypoints( sThingPlatform *ThisPlatform ) //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +void CNpcBranchPlatform::collidedWith( CThing *_thisThing ) +{ + switch(_thisThing->getThingType()) + { + case TYPE_PLAYER: + { + if ( m_detectCollision && m_isActive ) + { + CPlayer *player; + DVECTOR playerPos; + CRECT collisionArea; + + // Only interested in SBs feet colliding with the box (pkg) + player=(CPlayer*)_thisThing; + playerPos=player->getPos(); + collisionArea=getCollisionArea(); + if(playerPos.vx>=collisionArea.x1&&playerPos.vx<=collisionArea.x2&& + playerPos.vy>=collisionArea.y1&&playerPos.vy<=collisionArea.y2) + { + if ( ( m_reversed && playerPos.vx <= Pos.vx ) || ( !m_reversed && playerPos.vx >= Pos.vx ) ) + { + player->setPlatform( this ); + + if(getHeightFromPlatformAtPosition(playerPos.vx,playerPos.vy)==0) + { + m_contact = true; + } + } + } + } + + break; + } + + default: + ASSERT(0); + break; + } +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + void CNpcBranchPlatform::processMovement( int _frames ) { s16 newAngle = getCollisionAngle(); @@ -209,17 +252,30 @@ void CNpcBranchPlatform::render() m_modelGfx->Render(renderPos,&rotation,&scale); #if defined (__USER_paul__) || defined (__USER_charles__) + DVECTOR size; DVECTOR centre; int halfLength; int x1,y1,x2,y2; centre=getCollisionCentre(); - halfLength=PLATFORMWIDTH/2; + 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; + x1=0; + x2=0; + y1=0; + y2=0; + + if ( m_reversed ) + { + x1=-halfLength*mcos(getCollisionAngle()&4095)>>12; + y1=-halfLength*msin(getCollisionAngle()&4095)>>12; + } + else + { + x2=+halfLength*mcos(getCollisionAngle()&4095)>>12; + y2=+halfLength*msin(getCollisionAngle()&4095)>>12; + } centre.vx-=offset.vx; centre.vy-=offset.vy; diff --git a/source/platform/pbranch.h b/source/platform/pbranch.h index 458a885f6..5f5d8e7c4 100644 --- a/source/platform/pbranch.h +++ b/source/platform/pbranch.h @@ -27,6 +27,8 @@ protected: virtual void setWaypoints( sThingPlatform *ThisPlatform ); virtual void processMovement( int _frames ); + virtual void collidedWith(CThing *_thisThing); + s32 m_angularVelocity; u8 m_reversed; }; diff --git a/source/platform/platform.cpp b/source/platform/platform.cpp index 880f10b4d..b1f706d83 100644 --- a/source/platform/platform.cpp +++ b/source/platform/platform.cpp @@ -310,6 +310,8 @@ void CNpcPlatform::init() m_isShuttingDown = false; + m_platformWidth = PLATFORMWIDTH; + m_npcPath.initPath(); } @@ -558,7 +560,7 @@ void CNpcPlatform::calculateBoundingBoxSize() angle=getCollisionAngle(); centre=getCollisionCentre(); - halfLength=PLATFORMWIDTH/2; + halfLength=m_platformWidth/2; x1=-halfLength*mcos(angle&4095)>>12; y1=-halfLength*msin(angle&4095)>>12; @@ -746,12 +748,14 @@ void CNpcPlatform::render() // AddPrimToList(F4,2); #if defined (__USER_paul__) || defined (__USER_charles__) + DVECTOR size; DVECTOR centre; int halfLength; int x1,y1,x2,y2; centre=getCollisionCentre(); - halfLength=PLATFORMWIDTH/2; + size=getCollisionSize(); + halfLength=size.vx>>1; x1=-halfLength*mcos(getCollisionAngle()&4095)>>12; y1=-halfLength*msin(getCollisionAngle()&4095)>>12; diff --git a/source/platform/platform.h b/source/platform/platform.h index b8a7be6ed..62462deff 100644 --- a/source/platform/platform.h +++ b/source/platform/platform.h @@ -199,6 +199,8 @@ protected: CModelGfx *m_modelGfx; u8 m_isShuttingDown; + u8 m_platformWidth; + virtual void collidedWith(CThing *_thisThing); static NPC_PLATFORM_UNIT_TYPE mapEditConvertTable[NPC_PLATFORM_TYPE_MAX]; diff --git a/source/platform/pseesaw.cpp b/source/platform/pseesaw.cpp index 500fba0a0..9c264d6d9 100644 --- a/source/platform/pseesaw.cpp +++ b/source/platform/pseesaw.cpp @@ -141,12 +141,14 @@ void CNpcSeesawPlatform::render() m_modelGfx->Render(renderPos,&rotation,&scale); #if defined (__USER_paul__) || defined (__USER_charles__) + DVECTOR size; DVECTOR centre; int halfLength; int x1,y1,x2,y2; centre=getCollisionCentre(); - halfLength=PLATFORMWIDTH/2; + size=getCollisionSize(); + halfLength=size.vx>>1; x1=-halfLength*mcos(getCollisionAngle()&4095)>>12; y1=-halfLength*msin(getCollisionAngle()&4095)>>12;