2001-02-20 23:53:35 +01:00
|
|
|
/*=========================================================================
|
|
|
|
|
|
|
|
pickup.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\pickup.h"
|
|
|
|
|
|
|
|
#ifndef __LEVEL_LEVEL_H__
|
|
|
|
#include "level\level.h"
|
|
|
|
#endif
|
|
|
|
|
2001-05-18 23:03:51 +02:00
|
|
|
#ifndef __PLAYER_PLAYER_H__
|
|
|
|
#include "player\player.h"
|
|
|
|
#endif
|
|
|
|
|
2001-02-20 23:53:35 +01:00
|
|
|
// For the factory..
|
|
|
|
|
|
|
|
#ifndef __PICKUPS_PHEALTH_H__
|
|
|
|
#include "pickups\phealth.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __PICKUPS_PLIFE_H__
|
|
|
|
#include "pickups\plife.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __PICKUPS_PSPATULA_H__
|
|
|
|
#include "pickups\pspatula.h"
|
|
|
|
#endif
|
|
|
|
|
2001-02-21 18:13:37 +01:00
|
|
|
#ifndef __PICKUPS_PJLAMMO_H__
|
|
|
|
#include "pickups\pjlammo.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __PICKUPS_PBUBMIX_H__
|
|
|
|
#include "pickups\pbubmix.h"
|
|
|
|
#endif
|
|
|
|
|
2001-03-30 19:47:00 +02:00
|
|
|
#ifndef __PICKUPS_PBLOWER_H__
|
|
|
|
#include "pickups\pblower.h"
|
|
|
|
#endif
|
|
|
|
|
2001-02-21 18:13:37 +01:00
|
|
|
#ifndef __PICKUPS_PGLASSES_H__
|
|
|
|
#include "pickups\pglasses.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __PICKUPS_PSHOES_H__
|
|
|
|
#include "pickups\pshoes.h"
|
|
|
|
#endif
|
|
|
|
|
2001-02-21 23:33:17 +01:00
|
|
|
#ifndef __PICKUPS_PBALLOON_H__
|
|
|
|
#include "pickups\pballoon.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __PICKUPS_PHELMET_H__
|
|
|
|
#include "pickups\phelmet.h"
|
|
|
|
#endif
|
|
|
|
|
2001-03-31 04:05:24 +02:00
|
|
|
#ifndef __PICKUPS_PNET_H__
|
|
|
|
#include "pickups\pnet.h"
|
|
|
|
#endif
|
|
|
|
|
2001-02-21 18:13:37 +01:00
|
|
|
#ifndef __PICKUPS_PQUEST_H__
|
|
|
|
#include "pickups\pquest.h"
|
|
|
|
#endif
|
|
|
|
|
2001-05-25 20:43:47 +02:00
|
|
|
#include "game/game.h"
|
2001-02-20 23:53:35 +01:00
|
|
|
|
|
|
|
/* Std Lib
|
|
|
|
------- */
|
|
|
|
|
|
|
|
/* Data
|
|
|
|
---- */
|
|
|
|
|
2001-04-20 16:53:35 +02:00
|
|
|
#ifndef __SPR_SPRITES_H__
|
|
|
|
#include <sprites.h>
|
2001-02-20 23:53:35 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Tyepdefs && Defines
|
|
|
|
------------------- */
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Structure defintions
|
|
|
|
-------------------- */
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function Prototypes
|
|
|
|
------------------- */
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Vars
|
|
|
|
---- */
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
|
|
|
void CBasePickup::init()
|
|
|
|
{
|
2001-02-26 21:42:25 +01:00
|
|
|
CPickupThing::init();
|
2001-02-20 23:53:35 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
|
|
|
void CBasePickup::shutdown()
|
|
|
|
{
|
2001-02-26 21:42:25 +01:00
|
|
|
CPickupThing::shutdown();
|
2001-02-20 23:53:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
2001-02-21 23:33:17 +01:00
|
|
|
#include "pad\pads.h"
|
2001-02-20 23:53:35 +01:00
|
|
|
void CBasePickup::think(int _frames)
|
|
|
|
{
|
2001-02-26 21:42:25 +01:00
|
|
|
CPickupThing::think(_frames);
|
2001-02-21 23:33:17 +01:00
|
|
|
thinkPickup(_frames);
|
2001-02-20 23:53:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
|
|
|
void CBasePickup::render()
|
|
|
|
{
|
2001-02-21 23:33:17 +01:00
|
|
|
DVECTOR ofs,pos;
|
|
|
|
int visibilityRadius;
|
|
|
|
|
2001-02-26 21:42:25 +01:00
|
|
|
CPickupThing::render();
|
2001-02-21 23:33:17 +01:00
|
|
|
|
|
|
|
ofs=CLevel::getCameraPos();
|
|
|
|
pos.vx=Pos.vx-ofs.vx;
|
|
|
|
pos.vy=Pos.vy-ofs.vy;
|
|
|
|
visibilityRadius=getVisibilityRadius();
|
|
|
|
if(pos.vx>0-visibilityRadius&&pos.vx<512+visibilityRadius&&
|
|
|
|
pos.vy>0-visibilityRadius&&pos.vy<256+visibilityRadius)
|
|
|
|
{
|
|
|
|
renderPickup(&pos);
|
|
|
|
}
|
2001-02-20 23:53:35 +01:00
|
|
|
}
|
|
|
|
|
2001-02-26 21:42:25 +01:00
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
|
|
|
void CBasePickup::collidedWith(CThing *_thisThing)
|
|
|
|
{
|
|
|
|
switch(_thisThing->getThingType())
|
|
|
|
{
|
|
|
|
case TYPE_PLAYER:
|
|
|
|
collect((CPlayer*)_thisThing);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
ASSERT(0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-02-20 23:53:35 +01:00
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
|
|
|
void CBasePickup::setPos(const DVECTOR *_pos)
|
|
|
|
{
|
|
|
|
Pos=*_pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
|
|
|
void CBasePickup::collect(class CPlayer *_player)
|
|
|
|
{
|
|
|
|
shutdown();
|
2001-05-29 18:38:09 +02:00
|
|
|
CThingManager::DeleteThing(this);
|
|
|
|
// delete this;
|
2001-02-20 23:53:35 +01:00
|
|
|
}
|
|
|
|
|
2001-02-21 23:33:17 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
2001-02-20 23:53:35 +01:00
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
2001-02-21 23:33:17 +01:00
|
|
|
void CBaseRespawningPickup::init()
|
2001-02-20 23:53:35 +01:00
|
|
|
{
|
2001-02-21 23:33:17 +01:00
|
|
|
CBasePickup::init();
|
|
|
|
m_respawnTime=0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
2001-02-27 17:59:50 +01:00
|
|
|
int respawnFlashFrames=50;
|
2001-02-21 23:33:17 +01:00
|
|
|
void CBaseRespawningPickup::think(int _frames)
|
|
|
|
{
|
2001-02-27 17:59:50 +01:00
|
|
|
if(m_respawnTime<=respawnFlashFrames)
|
2001-02-21 23:33:17 +01:00
|
|
|
{
|
|
|
|
CBasePickup::think(_frames);
|
|
|
|
}
|
2001-02-27 17:59:50 +01:00
|
|
|
|
|
|
|
if(m_respawnTime)
|
2001-02-21 23:33:17 +01:00
|
|
|
{
|
|
|
|
m_respawnTime-=_frames;
|
|
|
|
if(m_respawnTime<0)
|
|
|
|
{
|
|
|
|
m_respawnTime=0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
|
|
|
void CBaseRespawningPickup::render()
|
|
|
|
{
|
|
|
|
if(m_respawnTime==0||
|
2001-02-27 17:59:50 +01:00
|
|
|
m_respawnTime<respawnFlashFrames&&!(m_respawnTime&4))
|
2001-02-21 23:33:17 +01:00
|
|
|
{
|
|
|
|
CBasePickup::render();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
|
|
|
void CBaseRespawningPickup::collect(class CPlayer *_player)
|
|
|
|
{
|
|
|
|
m_respawnTime=getRespawnTime();
|
2001-02-20 23:53:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-05-18 23:03:51 +02:00
|
|
|
|
2001-05-29 20:22:49 +02:00
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
|
|
|
void CBaseWeaponPickup::init()
|
|
|
|
{
|
|
|
|
CBasePickup::init();
|
|
|
|
|
|
|
|
m_dontAutoPickUpUntilPlayerMovesOffMe=true;
|
|
|
|
m_collidedWithPlayer=true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
|
|
|
void CBaseWeaponPickup::think(int _frames)
|
|
|
|
{
|
|
|
|
CBasePickup::think(_frames);
|
|
|
|
|
|
|
|
if(!m_collidedWithPlayer)
|
|
|
|
{
|
|
|
|
m_dontAutoPickUpUntilPlayerMovesOffMe=false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_collidedWithPlayer=false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-05-18 23:03:51 +02:00
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
|
|
|
void CBaseWeaponPickup::collidedWith(CThing *_thisThing)
|
|
|
|
{
|
|
|
|
switch(_thisThing->getThingType())
|
|
|
|
{
|
|
|
|
case TYPE_PLAYER:
|
|
|
|
{
|
2001-05-29 20:22:49 +02:00
|
|
|
CPlayer *player;
|
|
|
|
player=(CPlayer*)_thisThing;
|
|
|
|
if(player->tryingToManuallyPickupWeapon()||
|
|
|
|
(!m_dontAutoPickUpUntilPlayerMovesOffMe&&player->tryingToAutomaticallyPickupWeapon()))
|
|
|
|
{
|
|
|
|
collect(player);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_collidedWithPlayer=true;
|
|
|
|
}
|
2001-05-18 23:03:51 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
ASSERT(0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
|
|
|
void CBaseWeaponSimplePickup::init()
|
|
|
|
{
|
|
|
|
sFrameHdr *fh;
|
|
|
|
|
|
|
|
CBaseWeaponPickup::init();
|
|
|
|
|
2001-05-25 20:43:47 +02:00
|
|
|
fh=CGameScene::getSpriteBank()->getFrameHeader(FRM__NET);
|
2001-05-18 23:03:51 +02:00
|
|
|
setCollisionSize(fh->W,fh->H);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
|
|
|
DVECTOR CBaseWeaponSimplePickup::getSizeForPlacement()
|
|
|
|
{
|
|
|
|
DVECTOR size;
|
|
|
|
sFrameHdr *fh;
|
|
|
|
|
2001-05-25 20:43:47 +02:00
|
|
|
fh=CGameScene::getSpriteBank()->getFrameHeader(getWeaponSpriteFrame());
|
2001-05-18 23:03:51 +02:00
|
|
|
size.vx=fh->W;
|
|
|
|
size.vy=fh->H;
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
|
|
|
void CBaseWeaponSimplePickup::renderPickup(DVECTOR *_pos)
|
|
|
|
{
|
|
|
|
SpriteBank *sprites;
|
|
|
|
sFrameHdr *fh;
|
|
|
|
int x,y;
|
|
|
|
|
2001-05-25 20:43:47 +02:00
|
|
|
sprites=CGameScene::getSpriteBank();
|
2001-05-18 23:03:51 +02:00
|
|
|
fh=sprites->getFrameHeader(getWeaponSpriteFrame());
|
|
|
|
x=_pos->vx-(fh->W/2);
|
|
|
|
y=_pos->vy-(fh->H/2);
|
|
|
|
sprites->printFT4(fh,x,y,0,0,OTPOS__PICKUP_POS);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-02-20 23:53:35 +01:00
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
2001-02-21 18:13:37 +01:00
|
|
|
Purpose: This is basically a factory method for making pickups :)
|
2001-02-20 23:53:35 +01:00
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
|
|
|
CBasePickup *createPickup(const PICKUP_TYPE _type,const DVECTOR *_pos)
|
|
|
|
{
|
|
|
|
CBasePickup *pickup;
|
2001-04-02 23:37:20 +02:00
|
|
|
DVECTOR pickupPos;
|
2001-02-20 23:53:35 +01:00
|
|
|
|
2001-05-25 20:43:47 +02:00
|
|
|
pickup = (CBasePickup*)CThingManager::GetThing(CThing::TYPE_PICKUP,_type);
|
|
|
|
if (!pickup)
|
2001-02-20 23:53:35 +01:00
|
|
|
switch(_type)
|
|
|
|
{
|
2001-02-27 17:59:50 +01:00
|
|
|
case PICKUP__BIG_HEALTH:
|
|
|
|
pickup=new ("LargeHealthPickup") CLargeHealthPickup();
|
2001-02-20 23:53:35 +01:00
|
|
|
break;
|
2001-02-27 17:59:50 +01:00
|
|
|
case PICKUP__MEDIUM_HEALTH:
|
|
|
|
pickup=new ("MediumHealthPickup") CMediumHealthPickup();
|
2001-02-20 23:53:35 +01:00
|
|
|
break;
|
2001-02-27 17:59:50 +01:00
|
|
|
case PICKUP__SMALL_HEALTH:
|
|
|
|
pickup=new ("SmallHealthPickup") CSmallHealthPickup();
|
2001-02-20 23:53:35 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PICKUP__LIFE:
|
|
|
|
pickup=new ("LifePickup") CLifePickup();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PICKUP__SPATULA:
|
|
|
|
pickup=new ("SpatulaPickup") CSpatulaPickup();
|
|
|
|
break;
|
|
|
|
|
2001-02-21 18:13:37 +01:00
|
|
|
case PICKUP__JELLY_LAUNCHER_AMMO:
|
|
|
|
pickup=new ("JellyLauncherAmmoPickup") CJellyLauncherAmmoPickup();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PICKUP__BUBBLE_MIXTURE:
|
|
|
|
pickup=new ("BubbleAmmoPickup") CBubbleMixturePickup();
|
|
|
|
break;
|
|
|
|
|
2001-03-31 04:05:24 +02:00
|
|
|
case PICKUP__BUBBLE_WAND:
|
|
|
|
pickup=new ("BubbleWandPickup") CBubbleWandPickup();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PICKUP__NET:
|
|
|
|
pickup=new ("NetPickup") CNetPickup();
|
|
|
|
break;
|
|
|
|
|
2001-02-21 18:13:37 +01:00
|
|
|
case PICKUP__GLASSES:
|
|
|
|
pickup=new ("GlassesPickup") CGlassesPickup();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PICKUP__SQUEAKY_SHOES:
|
|
|
|
pickup=new ("ShoesPickup") CShoesPickup();
|
|
|
|
break;
|
|
|
|
|
2001-02-21 23:33:17 +01:00
|
|
|
case PICKUP__BALLOON:
|
|
|
|
pickup=new ("BalloonPickup") CBalloonPickup();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PICKUP__HELMET:
|
|
|
|
pickup=new ("HelmetPickup") CHelmetPickup();
|
|
|
|
break;
|
|
|
|
|
2001-03-30 19:47:00 +02:00
|
|
|
case PICKUP__CORAL_BLOWER:
|
|
|
|
pickup=new ("CoralBlowerPickup") CCoralBlowerPickup();
|
|
|
|
break;
|
|
|
|
|
2001-05-24 20:21:14 +02:00
|
|
|
case PICKUP__QUEST_ITEM:
|
|
|
|
pickup=new ("QuestItemPickup") CQuestItemPickup();
|
2001-02-21 18:13:37 +01:00
|
|
|
break;
|
|
|
|
|
2001-04-19 21:18:22 +02:00
|
|
|
case PICKUP__BALLOON_AND_SPATULA:
|
|
|
|
pickup=new ("BalloonAndSpatulaPickup") CBalloonAndSpatulaPickup();
|
|
|
|
break;
|
|
|
|
|
2001-04-26 23:19:53 +02:00
|
|
|
case PICKUP__JELLY_LAUNCHER:
|
|
|
|
pickup=new ("JellylauncherPickup") CJellyLauncherPickup();
|
|
|
|
break;
|
|
|
|
|
2001-02-20 23:53:35 +01:00
|
|
|
default:
|
|
|
|
ASSERT(!"UNKNOWN PICKUP TYPE");
|
2001-04-19 21:18:22 +02:00
|
|
|
return NULL;
|
2001-02-20 23:53:35 +01:00
|
|
|
}
|
|
|
|
|
2001-05-25 20:43:47 +02:00
|
|
|
pickup->setThingSubType(_type);
|
2001-02-20 23:53:35 +01:00
|
|
|
pickup->init();
|
2001-04-02 23:37:20 +02:00
|
|
|
pickupPos=pickup->getSizeForPlacement();
|
|
|
|
pickupPos.vx=_pos->vx+(pickupPos.vx/2);
|
|
|
|
pickupPos.vy=_pos->vy+(pickupPos.vy/2)-16;
|
|
|
|
pickup->setPos(&pickupPos);
|
2001-02-20 23:53:35 +01:00
|
|
|
|
|
|
|
return pickup;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================
|
|
|
|
end */
|