2001-04-27 16:39:10 +02:00
|
|
|
/*=========================================================================
|
|
|
|
|
|
|
|
friend.cpp
|
|
|
|
|
|
|
|
Author: CRB
|
2001-05-25 21:08:35 +02:00
|
|
|
Created:
|
2001-04-27 16:39:10 +02:00
|
|
|
Project: Spongebob
|
2001-05-25 21:08:35 +02:00
|
|
|
Purpose:
|
2001-04-27 16:39:10 +02:00
|
|
|
|
|
|
|
Copyright (c) 2000 Climax Development Ltd
|
|
|
|
|
|
|
|
===========================================================================*/
|
|
|
|
|
|
|
|
#ifndef __FRIEND_FRIEND_H__
|
|
|
|
#include "friend\friend.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __GAME_GAME_H__
|
|
|
|
#include "game\game.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __VID_HEADER_
|
|
|
|
#include "system\vid.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __UTILS_HEADER__
|
|
|
|
#include "utils\utils.h"
|
|
|
|
#endif
|
|
|
|
|
2001-04-27 21:20:49 +02:00
|
|
|
#ifndef __FRIEND_FBBOY_H__
|
|
|
|
#include "friend\fbboy.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __FRIEND_FGARY_H__
|
|
|
|
#include "friend\fgary.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __FRIEND_FKRUSTY_H__
|
|
|
|
#include "friend\fkrusty.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __FRIEND_FMMAN_H__
|
|
|
|
#include "friend\fmman.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __FRIEND_FPATRICK_H__
|
|
|
|
#include "friend\fpatrick.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __FRIEND_FSANDY_H__
|
|
|
|
#include "friend\fsandy.h"
|
|
|
|
#endif
|
|
|
|
|
2001-04-27 17:09:10 +02:00
|
|
|
#ifndef __FRIEND_FSQUID_H__
|
|
|
|
#include "friend\fsquid.h"
|
|
|
|
#endif
|
|
|
|
|
2001-05-03 15:11:45 +02:00
|
|
|
#ifndef __FRIEND_FPLNKTON_H__
|
|
|
|
#include "friend\fplnkton.h"
|
|
|
|
#endif
|
|
|
|
|
2001-05-25 23:18:54 +02:00
|
|
|
#ifndef __PAD_PADS_H__
|
|
|
|
#include "pad\pads.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __GAME_CONVO_H__
|
|
|
|
#include "game\convo.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef __SPR_SPRITES_H__
|
|
|
|
#include <sprites.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
// These are temporary.. I'll clean them up when I can test them (pkg)
|
2001-05-29 16:51:05 +02:00
|
|
|
int strobespeed=500;
|
2001-05-25 23:18:54 +02:00
|
|
|
int strobebase=300;
|
2001-05-29 16:51:05 +02:00
|
|
|
int strobescale=200;
|
2001-05-25 23:18:54 +02:00
|
|
|
// These are temporary.. I'll clean them up when I can test them (pkg)
|
|
|
|
|
|
|
|
|
2001-04-27 16:39:10 +02:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Friend NPCs
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
CNpcFriend *CNpcFriend::Create(sThingActor *ThisActor)
|
|
|
|
{
|
|
|
|
CNpcFriend *friendNpc;
|
|
|
|
|
2001-05-25 20:43:47 +02:00
|
|
|
NPC_FRIEND_UNIT_TYPE Type = CNpcFriend::getTypeFromMapEdit( ThisActor->Type );
|
2001-04-27 16:39:10 +02:00
|
|
|
|
2001-05-25 20:43:47 +02:00
|
|
|
friendNpc = (CNpcFriend*)CThingManager::GetThing(CThing::TYPE_NPC,Type);
|
|
|
|
if (!friendNpc)
|
|
|
|
switch( Type )
|
2001-04-27 16:39:10 +02:00
|
|
|
{
|
2001-04-27 21:20:49 +02:00
|
|
|
case CNpcFriend::NPC_FRIEND_BARNACLE_BOY:
|
|
|
|
{
|
|
|
|
friendNpc = new ("barnacle boy") CNpcBarnacleBoyFriend;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case CNpcFriend::NPC_FRIEND_GARY:
|
|
|
|
{
|
|
|
|
friendNpc = new ("gary") CNpcGaryFriend;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case CNpcFriend::NPC_FRIEND_KRUSTY:
|
|
|
|
{
|
|
|
|
friendNpc = new ("krusty") CNpcKrustyFriend;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case CNpcFriend::NPC_FRIEND_MERMAID_MAN:
|
|
|
|
{
|
|
|
|
friendNpc = new ("mermaid man") CNpcMermaidManFriend;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case CNpcFriend::NPC_FRIEND_PATRICK:
|
|
|
|
{
|
|
|
|
friendNpc = new ("patrick") CNpcPatrickFriend;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case CNpcFriend::NPC_FRIEND_SANDY_CHEEKS:
|
|
|
|
{
|
|
|
|
friendNpc = new ("sandy cheeks") CNpcSandyFriend;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2001-04-27 16:39:10 +02:00
|
|
|
case CNpcFriend::NPC_FRIEND_SQUIDWARD:
|
|
|
|
{
|
2001-04-27 17:09:10 +02:00
|
|
|
friendNpc = new ("squidward") CNpcSquidwardFriend;
|
2001-04-27 16:39:10 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2001-05-03 15:11:45 +02:00
|
|
|
case CNpcFriend::NPC_FRIEND_PLANKTON:
|
|
|
|
{
|
|
|
|
friendNpc = new ("plankton") CNpcPlanktonFriend;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2001-04-27 16:39:10 +02:00
|
|
|
default:
|
|
|
|
{
|
2001-05-25 20:43:47 +02:00
|
|
|
SYSTEM_DBGMSG("UNKNOWN %i\n",Type);
|
2001-04-27 16:39:10 +02:00
|
|
|
friendNpc = NULL;
|
|
|
|
ASSERT(0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ASSERT( friendNpc );
|
|
|
|
|
2001-05-25 20:43:47 +02:00
|
|
|
friendNpc->setType( Type );
|
|
|
|
friendNpc->setThingSubType(Type);
|
2001-04-27 16:39:10 +02:00
|
|
|
|
|
|
|
u16 *PntList=(u16*)MakePtr(ThisActor,sizeof(sThingActor));
|
|
|
|
|
|
|
|
u16 newXPos, newYPos;
|
|
|
|
|
|
|
|
newXPos = (u16) *PntList;
|
|
|
|
PntList++;
|
|
|
|
newYPos = (u16) *PntList;
|
|
|
|
PntList++;
|
|
|
|
|
|
|
|
DVECTOR startPos;
|
|
|
|
startPos.vx = newXPos << 4;
|
2001-04-27 21:54:38 +02:00
|
|
|
startPos.vy = ( newYPos + 1 ) << 4;
|
2001-04-27 16:39:10 +02:00
|
|
|
|
|
|
|
friendNpc->init( startPos );
|
|
|
|
|
|
|
|
return( friendNpc );
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
CNpcFriend::NPC_FRIEND_UNIT_TYPE CNpcFriend::getTypeFromMapEdit( u16 newType )
|
|
|
|
{
|
|
|
|
return( mapEditConvertTable[newType - NPC_FRIEND_MAPEDIT_OFFSET] );
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
void CNpcFriend::init()
|
|
|
|
{
|
|
|
|
CNpcThing::init();
|
|
|
|
|
|
|
|
m_extension = EXTEND_RIGHT;
|
|
|
|
|
|
|
|
m_actorGfx = CActorPool::GetActor( (FileEquate) m_data[m_type].skelType );
|
|
|
|
|
2001-04-27 17:09:10 +02:00
|
|
|
m_animPlaying = true;
|
|
|
|
m_animNo = m_data[m_type].idleAnim;
|
2001-04-27 16:39:10 +02:00
|
|
|
m_frame = 0;
|
|
|
|
m_reversed = false;
|
2001-05-25 21:08:35 +02:00
|
|
|
m_platform = NULL;
|
2001-05-29 21:47:49 +02:00
|
|
|
|
|
|
|
// Get rid of the bloody auto-talk-to-npc stuff except in cd builds..
|
|
|
|
#if defined(__USER_CDBUILD__)
|
2001-05-25 23:18:54 +02:00
|
|
|
m_hasSpokenToSbYet=false;
|
2001-05-29 21:47:49 +02:00
|
|
|
#else
|
|
|
|
m_hasSpokenToSbYet=true;
|
|
|
|
#endif
|
|
|
|
|
2001-05-25 23:18:54 +02:00
|
|
|
m_iconStrobe=0;
|
2001-04-27 16:39:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
void CNpcFriend::init( DVECTOR initPos )
|
|
|
|
{
|
|
|
|
init();
|
|
|
|
Pos = initPos;
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2001-05-03 00:49:59 +02:00
|
|
|
void CNpcFriend::postInit()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2001-04-27 16:39:10 +02:00
|
|
|
void CNpcFriend::shutdown()
|
|
|
|
{
|
|
|
|
delete m_actorGfx;
|
|
|
|
CNpcThing::shutdown();
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
void CNpcFriend::think(int _frames)
|
|
|
|
{
|
|
|
|
CNpcThing::think(_frames);
|
|
|
|
|
2001-04-27 17:09:10 +02:00
|
|
|
if ( m_animPlaying )
|
2001-04-27 16:39:10 +02:00
|
|
|
{
|
2001-04-27 17:09:10 +02:00
|
|
|
s32 frameCount;
|
2001-04-27 16:39:10 +02:00
|
|
|
|
2001-04-27 17:09:10 +02:00
|
|
|
frameCount = m_actorGfx->getFrameCount( m_animNo );
|
2001-04-27 16:39:10 +02:00
|
|
|
|
2001-04-27 17:09:10 +02:00
|
|
|
s32 frameShift = ( _frames << 8 ) >> 1;
|
|
|
|
|
|
|
|
if ( ( frameCount << 8 ) - m_frame > frameShift )
|
|
|
|
{
|
|
|
|
m_frame += frameShift;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_frame = ( frameCount - 1 ) << 8;
|
|
|
|
m_animPlaying = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-04-27 21:54:38 +02:00
|
|
|
m_animNo = m_data[m_type].idleAnim;
|
|
|
|
m_animPlaying = true;
|
|
|
|
m_frame = 0;
|
2001-04-27 16:39:10 +02:00
|
|
|
}
|
2001-05-25 23:18:54 +02:00
|
|
|
|
|
|
|
m_iconStrobe=(m_iconStrobe+(strobespeed))&4095;
|
2001-04-27 16:39:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2001-05-25 23:18:54 +02:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
int m_control,m_iconFrame;
|
|
|
|
} ICON_MAP;
|
|
|
|
static const ICON_MAP s_iconMap[]=
|
|
|
|
{
|
|
|
|
{ PAD_UP, FRM__BUTU },
|
|
|
|
{ PAD_DOWN, FRM__BUTD },
|
|
|
|
{ PAD_LEFT, FRM__BUTL },
|
|
|
|
{ PAD_RIGHT, FRM__BUTR },
|
|
|
|
{ PAD_CROSS, FRM__BUTX },
|
|
|
|
{ PAD_SQUARE, FRM__BUTS },
|
|
|
|
{ PAD_CIRCLE, FRM__BUTC },
|
|
|
|
{ PAD_TRIANGLE, FRM__BUTT },
|
|
|
|
};
|
|
|
|
|
2001-04-27 16:39:10 +02:00
|
|
|
void CNpcFriend::render()
|
|
|
|
{
|
|
|
|
CNpcThing::render();
|
|
|
|
|
2001-05-10 18:16:57 +02:00
|
|
|
// Render
|
2001-04-27 16:39:10 +02:00
|
|
|
|
2001-05-10 18:16:57 +02:00
|
|
|
if (canRender())
|
2001-04-27 16:39:10 +02:00
|
|
|
{
|
2001-05-10 18:16:57 +02:00
|
|
|
DVECTOR &renderPos=getRenderPos();
|
2001-04-27 20:30:19 +02:00
|
|
|
|
2001-05-10 18:16:57 +02:00
|
|
|
m_actorGfx->Render(renderPos,m_animNo,(m_frame>>8),m_reversed);
|
|
|
|
|
|
|
|
sBBox boundingBox = m_actorGfx->GetBBox();
|
2001-05-25 21:08:35 +02:00
|
|
|
boundingBox.YMax = 0;
|
2001-05-10 18:16:57 +02:00
|
|
|
setCollisionSize( ( boundingBox.XMax - boundingBox.XMin ), ( boundingBox.YMax - boundingBox.YMin ) );
|
|
|
|
setCollisionCentreOffset( ( boundingBox.XMax + boundingBox.XMin ) >> 1, ( boundingBox.YMax + boundingBox.YMin ) >> 1 );
|
2001-05-25 23:18:54 +02:00
|
|
|
|
|
|
|
if(m_hasSpokenToSbYet&&!CConversation::isActive())
|
|
|
|
{
|
|
|
|
const ICON_MAP *map;
|
|
|
|
int control;
|
|
|
|
sFrameHdr *fh;
|
|
|
|
int size;
|
|
|
|
DVECTOR iconPos;
|
|
|
|
|
|
|
|
map=s_iconMap;
|
|
|
|
control=CPadConfig::getButton(CPadConfig::PAD_CFG_UP);
|
|
|
|
while(map->m_control!=control)
|
|
|
|
{
|
|
|
|
map++;
|
|
|
|
}
|
|
|
|
fh=CGameScene::getSpriteBank()->getFrameHeader(map->m_iconFrame);
|
|
|
|
size=strobebase+((msin(m_iconStrobe)*strobescale)>>12);
|
|
|
|
iconPos=getRenderPos();
|
2001-05-29 16:51:05 +02:00
|
|
|
iconPos.vx-=fh->W/2;
|
|
|
|
iconPos.vy-=getCollisionSize().vy+(fh->H*2);
|
2001-05-25 23:18:54 +02:00
|
|
|
CGameScene::getSpriteBank()->printFT4Scaled(fh,iconPos.vx,iconPos.vy,0,0,0,size);
|
|
|
|
}
|
2001-04-27 16:39:10 +02:00
|
|
|
}
|
2001-05-10 18:16:57 +02:00
|
|
|
|
2001-04-27 16:39:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2001-05-02 00:06:59 +02:00
|
|
|
void CNpcFriend::collidedWith( CThing *_thisThing )
|
|
|
|
{
|
|
|
|
switch(_thisThing->getThingType())
|
|
|
|
{
|
|
|
|
case TYPE_PLAYER:
|
|
|
|
{
|
|
|
|
CPlayer *player = (CPlayer *) _thisThing;
|
|
|
|
|
2001-05-25 23:18:54 +02:00
|
|
|
if ( !m_hasSpokenToSbYet||player->isTryingToConversateWithFriend() )
|
2001-05-02 00:06:59 +02:00
|
|
|
{
|
2001-05-25 23:18:54 +02:00
|
|
|
m_hasSpokenToSbYet=true;
|
2001-05-02 00:06:59 +02:00
|
|
|
startConderversation();
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
ASSERT(0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2001-05-01 23:05:14 +02:00
|
|
|
void CNpcFriend::startConderversation()
|
2001-04-27 16:39:10 +02:00
|
|
|
{
|
2001-05-01 23:05:14 +02:00
|
|
|
// I am 'avin a fayg
|
|
|
|
}
|