2001-02-21 16:35:38 +01:00
|
|
|
/*=========================================================================
|
|
|
|
|
|
|
|
pquest.cpp
|
|
|
|
|
|
|
|
Author: PKG
|
|
|
|
Created:
|
|
|
|
Project: Spongebob
|
|
|
|
Purpose:
|
|
|
|
|
|
|
|
Copyright (c) 2001 Climax Development Ltd
|
|
|
|
|
|
|
|
===========================================================================*/
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Includes
|
|
|
|
-------- */
|
|
|
|
|
|
|
|
#ifndef __GFX_SPRBANK_H__
|
|
|
|
#include "gfx\sprbank.h" // Damnit.. include order! :( (pkg)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "pickups\pquest.h"
|
|
|
|
|
|
|
|
#ifndef __MATHTABLE_HEADER__
|
|
|
|
#include "utils\mathtab.h"
|
|
|
|
#endif
|
|
|
|
|
2001-02-21 18:13:37 +01:00
|
|
|
#ifndef __PRIM_HEADER__
|
|
|
|
#include "gfx\prim.h"
|
|
|
|
#endif
|
|
|
|
|
2001-04-19 22:46:43 +02:00
|
|
|
#ifndef __GFX_OTPOS_H__
|
|
|
|
#include "gfx\otpos.h"
|
|
|
|
#endif
|
|
|
|
|
2001-05-24 20:21:14 +02:00
|
|
|
#ifndef __GAME_GAME_H__
|
|
|
|
#include "game\game.h"
|
|
|
|
#endif
|
|
|
|
|
2001-05-25 20:43:47 +02:00
|
|
|
#include "game/game.h"
|
2001-02-21 16:35:38 +01:00
|
|
|
|
|
|
|
/* Std Lib
|
|
|
|
------- */
|
|
|
|
|
|
|
|
/* Data
|
|
|
|
---- */
|
|
|
|
|
2001-04-20 16:53:35 +02:00
|
|
|
#ifndef __SPR_SPRITES_H__
|
|
|
|
#include <sprites.h>
|
2001-02-21 16:35:38 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Tyepdefs && Defines
|
|
|
|
------------------- */
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Structure defintions
|
|
|
|
-------------------- */
|
|
|
|
|
2001-05-24 20:21:14 +02:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
u8 m_chapter,m_level;
|
|
|
|
u16 m_gfxFrame;
|
|
|
|
} sQuestItemMap;
|
|
|
|
|
|
|
|
|
2001-02-21 16:35:38 +01:00
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function Prototypes
|
|
|
|
------------------- */
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Vars
|
|
|
|
---- */
|
|
|
|
|
2001-05-24 20:21:14 +02:00
|
|
|
static const sQuestItemMap s_questItemMap[]=
|
|
|
|
{
|
2001-05-29 21:48:47 +02:00
|
|
|
{ 1,1, FRM__C1_L1_QUEST_ITEM },
|
|
|
|
{ 1,2, FRM__C1_L2_QUEST_ITEM },
|
|
|
|
{ 1,3, FRM__C1_L3_QUEST_ITEM },
|
|
|
|
{ 1,4, FRM__C1_L4_QUEST_ITEM },
|
|
|
|
{ 2,1, FRM__C2_L1_QUEST_ITEM },
|
|
|
|
{ 2,2, FRM__C2_L2_QUEST_ITEM },
|
|
|
|
{ 2,3, FRM__C2_L3_QUEST_ITEM },
|
|
|
|
{ 2,4, FRM__C2_L4_QUEST_ITEM },
|
|
|
|
{ 3,1, FRM__C3_L1_QUEST_ITEM },
|
|
|
|
{ 3,2, FRM__C3_L2_QUEST_ITEM },
|
|
|
|
{ 3,3, FRM__C3_L3_QUEST_ITEM },
|
|
|
|
{ 3,4, FRM__C3_L4_QUEST_ITEM },
|
|
|
|
{ 4,1, FRM__C4_QUEST_ITEM_1 },
|
|
|
|
{ 4,2, FRM__C4_QUEST_ITEM_1 },
|
|
|
|
{ 4,3, FRM__C4_QUEST_ITEM_1 },
|
|
|
|
{ 4,4, FRM__C4_QUEST_ITEM_2 },
|
|
|
|
{ 5,1, FRM__C5_L1_QUEST_ITEM },
|
|
|
|
{ 5,2, FRM__C5_L2_QUEST_ITEM },
|
|
|
|
{ 5,3, FRM__C5_L3_QUEST_ITEM },
|
|
|
|
{ 5,4, FRM__C5_L4_QUEST_ITEM },
|
2001-05-24 20:21:14 +02:00
|
|
|
};
|
|
|
|
static const int s_numQuestItemMap=sizeof(s_questItemMap)/sizeof(sQuestItemMap);
|
|
|
|
|
|
|
|
|
2001-02-21 16:35:38 +01:00
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
2001-05-24 20:21:14 +02:00
|
|
|
void CQuestItemPickup::init()
|
2001-02-21 16:35:38 +01:00
|
|
|
{
|
2001-05-24 20:21:14 +02:00
|
|
|
int chapter,level;
|
|
|
|
const sQuestItemMap *qi;
|
|
|
|
int i;
|
|
|
|
sFrameHdr *fh;
|
|
|
|
|
2001-04-20 18:57:05 +02:00
|
|
|
|
2001-02-21 16:35:38 +01:00
|
|
|
CBasePickup::init();
|
2001-02-21 18:13:37 +01:00
|
|
|
m_pingFrame=0;
|
2001-04-20 18:57:05 +02:00
|
|
|
|
2001-05-24 20:21:14 +02:00
|
|
|
chapter=GameScene.getChapterNumber();
|
|
|
|
level=GameScene.getLevelNumber();
|
|
|
|
m_gfxFrame=-1;
|
|
|
|
qi=s_questItemMap;
|
|
|
|
for(i=0;i<s_numQuestItemMap;i++)
|
|
|
|
{
|
|
|
|
if(qi->m_chapter==chapter&&qi->m_level==level)
|
|
|
|
{
|
|
|
|
m_gfxFrame=qi->m_gfxFrame;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
qi++;
|
|
|
|
}
|
|
|
|
ASSERT(m_gfxFrame!=-1);
|
|
|
|
|
2001-05-25 20:43:47 +02:00
|
|
|
fh=CGameScene::getSpriteBank()->getFrameHeader(m_gfxFrame);
|
2001-04-20 18:57:05 +02:00
|
|
|
setCollisionSize(fh->W,fh->H);
|
2001-02-21 16:35:38 +01:00
|
|
|
}
|
|
|
|
|
2001-04-02 23:37:20 +02:00
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
2001-05-24 20:21:14 +02:00
|
|
|
DVECTOR CQuestItemPickup::getSizeForPlacement()
|
2001-04-02 23:37:20 +02:00
|
|
|
{
|
|
|
|
DVECTOR size;
|
|
|
|
sFrameHdr *fh;
|
|
|
|
|
2001-05-25 20:43:47 +02:00
|
|
|
fh=CGameScene::getSpriteBank()->getFrameHeader(m_gfxFrame);
|
2001-04-02 23:37:20 +02:00
|
|
|
size.vx=fh->W;
|
|
|
|
size.vy=fh->H;
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
2001-02-21 16:35:38 +01:00
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
2001-05-24 20:21:14 +02:00
|
|
|
void CQuestItemPickup::collect(class CPlayer *_player)
|
2001-02-21 23:33:17 +01:00
|
|
|
{
|
|
|
|
CBasePickup::collect(_player);
|
|
|
|
}
|
|
|
|
|
2001-02-21 18:13:37 +01:00
|
|
|
int quest_pingframes=50;
|
|
|
|
int quest_pingwaitframes=100;
|
|
|
|
int quest_pingsize=100;
|
|
|
|
int quest_pingr=0;
|
|
|
|
int quest_pingg=255;
|
|
|
|
int quest_pingb=0;
|
|
|
|
int quest_pingsegments=16;
|
|
|
|
int quest_transmode=1;
|
2001-02-21 23:33:17 +01:00
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
2001-05-24 20:21:14 +02:00
|
|
|
int CQuestItemPickup::getVisibilityRadius()
|
2001-02-21 23:33:17 +01:00
|
|
|
{
|
|
|
|
return quest_pingsize;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
2001-05-24 20:21:14 +02:00
|
|
|
void CQuestItemPickup::thinkPickup(int _frames)
|
2001-02-21 16:35:38 +01:00
|
|
|
{
|
2001-02-21 18:13:37 +01:00
|
|
|
m_pingFrame+=_frames;
|
|
|
|
if(m_pingFrame>(quest_pingframes+quest_pingwaitframes))
|
|
|
|
{
|
|
|
|
// Do sound too.. (pkg)
|
|
|
|
m_pingFrame=0;
|
|
|
|
}
|
2001-02-21 16:35:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
2001-02-21 18:13:37 +01:00
|
|
|
Purpose: LOTS to optimise here.. (pkg)
|
2001-02-21 16:35:38 +01:00
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
2001-05-24 20:21:14 +02:00
|
|
|
void CQuestItemPickup::renderPickup(DVECTOR *_pos)
|
2001-02-21 16:35:38 +01:00
|
|
|
{
|
|
|
|
SpriteBank *sprites;
|
|
|
|
sFrameHdr *fh;
|
|
|
|
int x,y;
|
|
|
|
|
2001-05-25 20:43:47 +02:00
|
|
|
sprites=CGameScene::getSpriteBank();
|
2001-05-24 20:21:14 +02:00
|
|
|
fh=sprites->getFrameHeader(m_gfxFrame);
|
2001-02-21 23:33:17 +01:00
|
|
|
x=_pos->vx-(fh->W/2);
|
|
|
|
y=_pos->vy-(fh->H/2);
|
2001-04-19 22:46:43 +02:00
|
|
|
sprites->printFT4(fh,x,y,0,0,OTPOS__PICKUP_POS);
|
2001-02-21 16:35:38 +01:00
|
|
|
|
2001-02-21 18:13:37 +01:00
|
|
|
if(m_pingFrame<quest_pingframes)
|
|
|
|
{
|
|
|
|
int radius;
|
|
|
|
int endr,endg,endb;
|
|
|
|
int angle;
|
|
|
|
DVECTOR p1,p2;
|
|
|
|
int i;
|
|
|
|
POLY_G3 *g3;
|
|
|
|
POLY_FT3 *ft3;
|
|
|
|
|
2001-02-21 23:33:17 +01:00
|
|
|
x=_pos->vx;
|
|
|
|
y=_pos->vy;
|
2001-02-21 18:13:37 +01:00
|
|
|
radius=(quest_pingsize*m_pingFrame)/quest_pingframes;
|
|
|
|
endr=(quest_pingr*(quest_pingframes-m_pingFrame))/quest_pingframes;
|
|
|
|
endg=(quest_pingg*(quest_pingframes-m_pingFrame))/quest_pingframes;
|
|
|
|
endb=(quest_pingb*(quest_pingframes-m_pingFrame))/quest_pingframes;
|
|
|
|
|
|
|
|
p1.vx=x;
|
|
|
|
p1.vy=y+radius;
|
|
|
|
for(i=0;i<quest_pingsegments;i++)
|
|
|
|
{
|
|
|
|
angle=(4095*(i+1))/quest_pingsegments;
|
|
|
|
p2.vx=x+((msin(angle)*radius)>>12);
|
|
|
|
p2.vy=y+((mcos(angle)*radius)>>12);
|
|
|
|
g3=GetPrimG3();
|
|
|
|
setXY3(g3,x,y,p1.vx,p1.vy,p2.vx,p2.vy);
|
|
|
|
setRGB0(g3,0,0,0);
|
|
|
|
setRGB1(g3,endr,endg,endb);
|
|
|
|
setRGB2(g3,endr,endg,endb);
|
|
|
|
setShadeTex(g3,0);
|
|
|
|
setSemiTrans(g3,1);
|
2001-04-19 22:46:43 +02:00
|
|
|
AddPrimToList(g3,OTPOS__PICKUP_POS+1);
|
2001-02-21 18:13:37 +01:00
|
|
|
p1=p2;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Trans
|
|
|
|
ft3=GetPrimFT3();
|
|
|
|
setShadeTex(ft3,1);
|
|
|
|
setSemiTrans(ft3,1);
|
|
|
|
ft3->tpage=(quest_transmode<<5);
|
|
|
|
setXY3(ft3,512,512,512,512,512,512);
|
2001-04-19 22:46:43 +02:00
|
|
|
AddPrimToList(ft3,OTPOS__PICKUP_POS+1);
|
2001-02-21 18:13:37 +01:00
|
|
|
}
|
2001-02-21 16:35:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*===========================================================================
|
|
|
|
end */
|