SBSPSS/source/triggers/trigger.cpp

551 lines
14 KiB
C++
Raw Normal View History

2001-05-29 21:25:37 +02:00
/*=========================================================================
trigger source file
Author: Davey Boy
Created:
Project: Spongebob
Purpose:
Copyright (c) 2001 Climax Development Ltd
===========================================================================*/
#ifndef __TRIGGER_TRIGGER_HEADER__
#include "triggers\trigger.h"
#endif
2001-06-12 01:30:23 +02:00
#ifndef __TRIGGERS_TLEVEXIT_H__
#include "triggers\tlevexit.h"
#endif
2001-05-29 21:25:37 +02:00
#ifndef __TRIGGERS_TRESTART_H__
#include "triggers\trestart.h"
#endif
#ifndef __TRIGGERS_TTELEPRT_H__
#include "triggers\tteleprt.h"
#endif
#ifndef __TRIGGERS_TCAMLOCK_H__
#include "triggers\tcamlock.h"
#endif
#ifndef __TRIGGERS_TWATER_H__
#include "triggers\twater.h"
#endif
2001-05-30 18:52:52 +02:00
#ifndef __TRIGGERS_TPLATFRM_H__
#include "triggers\tplatfrm.h"
#endif
2001-05-30 22:24:02 +02:00
#ifndef __TRIGGERS_TGARYGO_H__
#include "triggers\tgarygo.h"
#endif
2001-06-02 00:03:24 +02:00
#ifndef __TRIGGERS_TFEMIT_H__
#include "triggers\tfemit.h"
#endif
#ifndef __TRIGGERS_TIFEMIT_H__
#include "triggers\tifemit.h"
#endif
2001-06-04 16:04:39 +02:00
#ifndef __TRIGGERS_TBEMIT_H__
#include "triggers\tbemit.h"
#endif
2001-06-04 14:54:44 +02:00
#ifndef __TRIGGERS_TGGLEFT_H__
#include "triggers\tggleft.h"
#endif
2001-06-04 15:20:30 +02:00
#ifndef __TRIGGERS_TGGRIGHT_H__
#include "triggers\tggright.h"
#endif
2001-06-04 14:54:44 +02:00
#ifndef __TRIGGERS_TGSTOP_H__
#include "triggers\tgstop.h"
#endif
2001-06-04 21:01:17 +02:00
#ifndef __TRIGGERS_THAZARD_H__
#include "triggers\thazard.h"
#endif
2001-06-05 18:01:22 +02:00
#ifndef __TRIGGERS_THAZWALK_H__
#include "triggers\thazwalk.h"
#endif
2001-06-05 16:38:11 +02:00
#ifndef __TRIGGERS_TBGEYSER_H__
#include "triggers\tbgeyser.h"
#endif
2001-07-04 20:37:17 +02:00
#ifndef __TRIGGERS_TSECRET_H__
#include "triggers\tsecret.h"
#endif
2001-06-05 22:21:11 +02:00
#ifndef __TRIGGERS_TSEMIT_H__
#include "triggers\tsemit.h"
#endif
2001-06-06 15:27:46 +02:00
#ifndef __TRIGGERS_TSSWITCH_H__
#include "triggers\tsswitch.h"
#endif
2001-06-06 20:40:34 +02:00
#ifndef __TRIGGERS_TGBOWL_H__
#include "triggers\tgbowl.h"
#endif
2001-06-07 18:33:19 +02:00
#ifndef __TRIGGERS_TWDRIPEMIT_H__
#include "triggers\twdripemit.h"
#endif
#ifndef __TRIGGERS_TADRIPEMIT_H__
#include "triggers\tadripemit.h"
#endif
#ifndef __TRIGGERS_TODRIPEMIT_H__
#include "triggers\todripemit.h"
#endif
#ifndef __TRIGGERS_TLDRIPEMIT_H__
#include "triggers\tldripemit.h"
#endif
2001-06-07 20:41:59 +02:00
#ifndef __TRIGGERS_TABEMIT_H__
#include "triggers\tabemit.h"
#endif
#ifndef __TRIGGERS_TOBEMIT_H__
#include "triggers\tobemit.h"
#endif
#ifndef __TRIGGERS_TLBEMIT_H__
#include "triggers\tlbemit.h"
#endif
2001-06-08 15:35:08 +02:00
#ifndef __TRIGGERS_TSDOWNEMIT_H__
#include "triggers\tsdownemit.h"
#endif
#ifndef __TRIGGERS_TSLEFTEMIT_H__
#include "triggers\tsleftemit.h"
#endif
#ifndef __TRIGGERS_TSRIGHTEMIT_H__
#include "triggers\tsrightemit.h"
#endif
2001-06-15 23:24:14 +02:00
#ifndef __TRIGGERS_TWINDUP_H__
#include "triggers\twindup.h"
#endif
#ifndef __TRIGGERS_TWINDDOWN_H__
#include "triggers\twinddown.h"
#endif
#ifndef __TRIGGERS_TWINDLEFT_H__
#include "triggers\twindleft.h"
#endif
#ifndef __TRIGGERS_TWINDRIGHT_H__
#include "triggers\twindright.h"
#endif
2001-06-19 23:35:02 +02:00
#ifndef __TRIGGERS_TOILGEYSER_H__
#include "triggers\toilgeyser.h"
#endif
2001-06-25 23:47:22 +02:00
#ifndef __TRIGGERS_TBOSS_H__
#include "triggers\tboss.h"
#endif
2001-07-13 20:27:56 +02:00
#ifndef __TRIGGERS_TSPEECH_H__
#include "triggers\tspeech.h"
#endif
2001-07-26 22:00:55 +02:00
#ifndef __TRIGGERS_TLOOK_H__
#include "triggers\tlook.h"
#endif
2001-07-28 19:00:06 +02:00
#ifndef __TRIGGERS_TBUTTFLY_H__
#include "triggers\tbuttfly.h"
#endif
2001-05-29 21:25:37 +02:00
#ifndef __GAME_GAME_H__
#include "game\game.h"
#endif
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
CTrigger *CTrigger::Create(int Type)
{
CTrigger *trigger;
2001-05-29 22:31:02 +02:00
2001-05-29 21:25:37 +02:00
trigger = (CTrigger*)CThingManager::GetThing(CThing::TYPE_TRIGGER,Type);
if (!trigger)
switch( Type )
{
// Exit trigger
case TRIGGER_EXIT:
2001-06-12 01:30:23 +02:00
trigger=(CTrigger*)new ("LevelExitTrigger") CLevelExitTrigger();
2001-05-29 21:25:37 +02:00
break;
// Level respawn trigger
case TRIGGER_RESPAWN:
trigger=(CRestartPointTrigger*)new ("RestartTrigger") CRestartPointTrigger();
break;
// Teleport trigger
case TRIGGER_TELEPORT:
trigger=(CTeleportTrigger*)new ("TeleportTrigger") CTeleportTrigger();
break;
// Camera lock trigger
case TRIGGER_CAMLOCK:
2001-05-29 22:31:02 +02:00
trigger=(CCameraLockTrigger*)new ("CameraLockTrigger") CCameraLockTrigger();
2001-05-29 21:25:37 +02:00
break;
// In/Out of water triggers
2001-05-29 22:31:02 +02:00
case TRIGGER_INWATER:
2001-05-29 21:25:37 +02:00
trigger=(CInWaterTrigger*)new ("InWaterTrigger") CInWaterTrigger();
break;
2001-05-29 22:31:02 +02:00
case TRIGGER_OUTWATER:
2001-05-29 21:25:37 +02:00
trigger=(COutOfWaterTrigger*)new ("OutOfWaterTrigger") COutOfWaterTrigger();
break;
2001-05-30 18:52:52 +02:00
2001-05-30 22:24:02 +02:00
// Gary start trigger
2001-06-05 16:38:11 +02:00
case TRIGGER_GARY_START:
2001-06-04 14:54:44 +02:00
trigger=(CGaryStartTrigger*)new("GaryStartTrigger") CGaryStartTrigger();
2001-05-30 22:24:02 +02:00
break;
2001-06-04 14:54:44 +02:00
// Gary stop trigger
2001-06-05 16:38:11 +02:00
case TRIGGER_GARY_STOP:
2001-06-04 14:54:44 +02:00
trigger=(CGaryStopTrigger*)new("GaryStopTrigger") CGaryStopTrigger();
break;
// Gary go left trigger
2001-06-05 16:38:11 +02:00
case TRIGGER_GARY_GO_LEFT:
2001-06-04 14:54:44 +02:00
trigger=(CGaryGoLeftTrigger*)new("GaryGoLeftTrigger") CGaryGoLeftTrigger();
break;
2001-06-04 15:20:30 +02:00
// Gary go right trigger
2001-06-05 16:38:11 +02:00
case TRIGGER_GARY_GO_RIGHT:
2001-06-04 15:20:30 +02:00
trigger=(CGaryGoRightTrigger*)new("GaryGoRightTrigger") CGaryGoRightTrigger();
break;
2001-06-06 20:40:34 +02:00
// Gary bowl trigger
case TRIGGER_GARY_BOWL:
trigger=(CGaryBowlTrigger*)new("GaryBowlTrigger") CGaryBowlTrigger();
break;
2001-06-04 16:04:39 +02:00
// Flame emitter
2001-06-05 16:38:11 +02:00
case TRIGGER_FLAME_EMITTER:
2001-06-04 16:04:39 +02:00
trigger=(CFlameEmitterTrigger*)new( "FlameEmitterTrigger") CFlameEmitterTrigger();
break;
2001-06-05 16:38:11 +02:00
case TRIGGER_INTERMITTENT_FLAME_EMITTER:
case TRIGGER_INTERMITTENT_LEFT_FLAME_EMITTER:
case TRIGGER_INTERMITTENT_DOWN_FLAME_EMITTER:
2001-06-02 00:03:24 +02:00
trigger=(CIntermittentFlameEmitterTrigger*)new( "IntermittentFlameEmitterTrigger") CIntermittentFlameEmitterTrigger();
break;
2001-06-04 16:04:39 +02:00
// Bubble emitter
2001-06-05 16:38:11 +02:00
case TRIGGER_BUBBLE_EMITTER:
2001-06-04 16:04:39 +02:00
trigger=(CBubbleEmitterTrigger*)new( "BubbleEmitterTrigger") CBubbleEmitterTrigger();
break;
2001-06-07 20:41:59 +02:00
// Acid bubble emitter
case TRIGGER_ACID_BUBBLE_EMITTER:
trigger=(CAcidBubbleEmitterTrigger*)new( "AcidBubbleEmitterTrigger") CAcidBubbleEmitterTrigger();
break;
// Oil bubble emitter
case TRIGGER_OIL_BUBBLE_EMITTER:
trigger=(COilBubbleEmitterTrigger*)new( "OilBubbleEmitterTrigger") COilBubbleEmitterTrigger();
break;
// Lava bubble emitter
case TRIGGER_LAVA_BUBBLE_EMITTER:
trigger=(CLavaBubbleEmitterTrigger*)new( "LavaBubbleEmitterTrigger") CLavaBubbleEmitterTrigger();
break;
2001-06-05 16:38:11 +02:00
// Bubble geyser emitter
case TRIGGER_BUBBLE_GEYSER_EMITTER:
trigger=(CBubbleGeyserEmitterTrigger*)new( "BubbleGeyserEmitterTrigger") CBubbleGeyserEmitterTrigger();
break;
2001-06-05 22:21:11 +02:00
// Steam emitter
case TRIGGER_STEAM_EMITTER:
trigger=(CSteamEmitterTrigger*)new("SteamEmitterTrigger") CSteamEmitterTrigger();
2001-06-07 18:33:19 +02:00
break;
2001-06-08 15:35:08 +02:00
// Down steam emitter
case TRIGGER_STEAM_DOWN_EMITTER:
trigger=(CSteamDownEmitterTrigger*)new("SteamDownEmitterTrigger") CSteamDownEmitterTrigger();
break;
// Left steam emitter
case TRIGGER_STEAM_LEFT_EMITTER:
trigger=(CSteamLeftEmitterTrigger*)new("SteamLeftEmitterTrigger") CSteamLeftEmitterTrigger();
break;
// Right steam emitter
case TRIGGER_STEAM_RIGHT_EMITTER:
trigger=(CSteamRightEmitterTrigger*)new("SteamRightEmitterTrigger") CSteamRightEmitterTrigger();
break;
2001-06-07 18:33:19 +02:00
// Water drip emitter
case TRIGGER_WATER_DRIP_EMITTER:
trigger=(CWaterDripEmitterTrigger*)new("WaterDripEmitterTrigger") CWaterDripEmitterTrigger();
break;
// Acid drip emitter
case TRIGGER_ACID_DRIP_EMITTER:
trigger=(CAcidDripEmitterTrigger*)new("AcidDripEmitterTrigger") CAcidDripEmitterTrigger();
break;
// Oil drip emitter
case TRIGGER_OIL_DRIP_EMITTER:
trigger=(COilDripEmitterTrigger*)new("OilDripEmitterTrigger") COilDripEmitterTrigger();
break;
// Lava drip emitter
case TRIGGER_LAVA_DRIP_EMITTER:
trigger=(CLavaDripEmitterTrigger*)new("LavaDripEmitterTrigger") CLavaDripEmitterTrigger();
2001-06-05 22:21:11 +02:00
break;
2001-05-30 18:52:52 +02:00
case TRIGGER_PLATFORM:
trigger = (CPlatformTrigger*)new ("PlatformTrigger") CPlatformTrigger();
break;
2001-06-04 21:01:17 +02:00
case TRIGGER_HAZARD:
trigger = (CHazardTrigger*)new("HazardTrigger") CHazardTrigger();
break;
2001-06-05 18:01:22 +02:00
case TRIGGER_HAZARD_WALK:
trigger = (CHazardWalkTrigger*)new("HazardWalkTrigger") CHazardWalkTrigger();
break;
2001-06-06 15:27:46 +02:00
// Steam switch emitter
case TRIGGER_STEAM_SWITCH_EMITTER:
trigger=(CSteamSwitchEmitterTrigger*)new("SteamSwitchEmitterTrigger") CSteamSwitchEmitterTrigger();
break;
2001-06-15 23:24:14 +02:00
// Wind up
case TRIGGER_WIND_UP:
trigger = (CWindUpTrigger*)new("WindUpTrigger") CWindUpTrigger();
break;
// Wind down
case TRIGGER_WIND_DOWN:
trigger = (CWindDownTrigger*)new("WindDownTrigger") CWindDownTrigger();
break;
// Wind up
case TRIGGER_WIND_LEFT:
trigger = (CWindLeftTrigger*)new("WindLeftTrigger") CWindLeftTrigger();
break;
// Wind up
case TRIGGER_WIND_RIGHT:
trigger = (CWindRightTrigger*)new("WindRightTrigger") CWindRightTrigger();
break;
2001-06-19 23:35:02 +02:00
// Oil Geyser
case TRIGGER_OIL_GEYSER:
trigger = (COilGeyserTrigger*)new("OilGeyserTrigger") COilGeyserTrigger();
break;
2001-06-25 23:47:22 +02:00
// Boss Arena
case TRIGGER_BOSS_ARENA:
2001-07-04 20:37:17 +02:00
trigger = (CBossArenaTrigger*)new("BossArenaTrigger") CBossArenaTrigger();
break;
// Secret Area
case TRIGGER_SECRET_AREA:
trigger = (CSecretAreaTrigger*)new("SecretAreaTrigger") CSecretAreaTrigger();
2001-06-25 23:47:22 +02:00
break;
2001-07-13 20:27:56 +02:00
case TRIGGER_SPEECH_FIRST_NET:
{
trigger = (CSpeechTrigger*)new("SpeechTrigger") CSpeechTrigger();
CSpeechTrigger *speechTrigger = (CSpeechTrigger*) trigger;
speechTrigger->setData(0);
break;
}
case TRIGGER_SPEECH_FIRST_CORAL:
{
trigger = (CSpeechTrigger*)new("SpeechTrigger") CSpeechTrigger();
CSpeechTrigger *speechTrigger = (CSpeechTrigger*) trigger;
2001-07-13 21:38:13 +02:00
speechTrigger->setData(1);
2001-07-13 20:27:56 +02:00
break;
}
case TRIGGER_SPEECH_GARY_CH2L1:
{
trigger = (CSpeechTrigger*)new("SpeechTrigger") CSpeechTrigger();
CSpeechTrigger *speechTrigger = (CSpeechTrigger*) trigger;
2001-07-13 21:38:13 +02:00
speechTrigger->setData(2);
2001-07-13 20:27:56 +02:00
break;
}
case TRIGGER_SPEECH_BREAK_FLOOR:
{
trigger = (CSpeechTrigger*)new("SpeechTrigger") CSpeechTrigger();
CSpeechTrigger *speechTrigger = (CSpeechTrigger*) trigger;
2001-07-13 21:38:13 +02:00
speechTrigger->setData(3);
2001-07-13 20:27:56 +02:00
break;
}
case TRIGGER_SPEECH_BUBBLE_GEYSER:
{
trigger = (CSpeechTrigger*)new("SpeechTrigger") CSpeechTrigger();
CSpeechTrigger *speechTrigger = (CSpeechTrigger*) trigger;
2001-07-13 21:38:13 +02:00
speechTrigger->setData(4);
2001-07-13 20:27:56 +02:00
break;
}
case TRIGGER_SPEECH_RISING_PLATFORM:
{
trigger = (CSpeechTrigger*)new("SpeechTrigger") CSpeechTrigger();
CSpeechTrigger *speechTrigger = (CSpeechTrigger*) trigger;
2001-07-13 21:38:13 +02:00
speechTrigger->setData(5);
2001-07-13 20:27:56 +02:00
break;
}
case TRIGGER_SPEECH_FIRST_BUBBLE:
{
trigger = (CSpeechTrigger*)new("SpeechTrigger") CSpeechTrigger();
CSpeechTrigger *speechTrigger = (CSpeechTrigger*) trigger;
2001-07-13 21:38:13 +02:00
speechTrigger->setData(6);
2001-07-13 20:27:56 +02:00
break;
}
case TRIGGER_SPEECH_USE_BUBBLE:
{
trigger = (CSpeechTrigger*)new("SpeechTrigger") CSpeechTrigger();
CSpeechTrigger *speechTrigger = (CSpeechTrigger*) trigger;
2001-07-13 21:38:13 +02:00
speechTrigger->setData(7);
2001-07-13 20:27:56 +02:00
break;
}
case TRIGGER_SPEECH_WEIGHT:
{
trigger = (CSpeechTrigger*)new("SpeechTrigger") CSpeechTrigger();
CSpeechTrigger *speechTrigger = (CSpeechTrigger*) trigger;
2001-07-13 21:38:13 +02:00
speechTrigger->setData(8);
2001-07-13 20:27:56 +02:00
break;
}
2001-07-26 22:00:55 +02:00
case TRIGGER_CAMERAYPOSITIONTRIGGER:
trigger = (CLookTrigger*)new("LookTrigger") CLookTrigger();
break;
2001-07-28 19:00:06 +02:00
case TRIGGER_BUTTERFLY_ON:
trigger = (CButterflyTrigger*)new("ButterflyTrigger") CButterflyTrigger();
break;
2001-05-29 21:25:37 +02:00
default:
trigger=NULL;
}
ASSERT( trigger);
trigger->setThingSubType(Type);
trigger->init();
return( trigger);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
CTrigger *CTrigger::Create(sThingTrigger *ThisTrigger)
{
CTrigger *trigger=Create(ThisTrigger->Type);
2001-06-04 21:01:17 +02:00
2001-05-29 21:25:37 +02:00
trigger->setPositionAndSize(ThisTrigger->Pos.X<<4,ThisTrigger->Pos.Y<<4,ThisTrigger->Width<<4,ThisTrigger->Height<<4);
trigger->setTargetBox(ThisTrigger->TargetPos.X<<4,ThisTrigger->TargetPos.Y<<4,ThisTrigger->TargetSize.X<<4,ThisTrigger->TargetSize.Y<<4);
2001-07-26 22:00:55 +02:00
trigger->setVal(ThisTrigger->Val0);
2001-05-29 21:25:37 +02:00
2001-06-04 21:01:17 +02:00
switch( ThisTrigger->Type )
{
2001-06-05 16:38:11 +02:00
case TRIGGER_INTERMITTENT_LEFT_FLAME_EMITTER:
2001-06-04 21:01:17 +02:00
{
CIntermittentFlameEmitterTrigger *m_flameEmitter = (CIntermittentFlameEmitterTrigger *) trigger;
m_flameEmitter->setHeading( 3072 );
m_flameEmitter->setSize( ThisTrigger->Height<<4, ThisTrigger->Width<<4 );
break;
}
2001-06-05 16:38:11 +02:00
case TRIGGER_INTERMITTENT_DOWN_FLAME_EMITTER:
2001-06-04 21:01:17 +02:00
{
CIntermittentFlameEmitterTrigger *m_flameEmitter = (CIntermittentFlameEmitterTrigger *) trigger;
m_flameEmitter->setHeading( 2048 );
break;
}
default:
break;
}
2001-05-29 21:25:37 +02:00
return( trigger);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CTrigger::init()
{
2001-05-29 22:31:02 +02:00
CTriggerThing::init();
2001-05-29 21:25:37 +02:00
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CTrigger::shutdown()
{
2001-05-29 22:31:02 +02:00
CTriggerThing::shutdown();
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CTrigger::think(int _frames)
{
CTriggerThing::think(_frames);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CTrigger::render()
{
CTriggerThing::render();
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CTrigger::setPositionAndSize(int _x,int _y,int _w,int _h)
{
Pos.vx=_x+(_w/2);
Pos.vy=_y+(_h/2);
setCollisionSize(_w,_h);
2001-05-29 21:25:37 +02:00
}
2001-05-29 22:31:02 +02:00
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CTrigger::setTargetBox(int _x,int _y,int _w,int _h)
{
m_boxX1=_x;
m_boxY1=_y;
m_boxX2=_x+_w;
m_boxY2=_y+_h;
}
2001-07-26 22:00:55 +02:00
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CTrigger::setVal(int _val)
{
m_val0=_val;
}
2001-05-29 22:31:02 +02:00