From 396949c907d2401b6b64b9be1eb4bee55a9e2742 Mon Sep 17 00:00:00 2001 From: Charles Date: Wed, 23 May 2001 23:16:43 +0000 Subject: [PATCH] --- makefile.gaz | 6 ++- source/hazard/hazard.cpp | 11 ++++ source/hazard/hazard.h | 1 + source/level/level.cpp | 1 + source/platform/platdata.cpp | 13 +++++ source/platform/platform.cpp | 25 +++++++-- source/platform/platform.h | 2 + source/thing/thing.cpp | 51 +++++++++++++++++++ source/thing/thing.h | 1 + tools/Data/bin/MkLevel.ini | 5 +- tools/MapEdit/Hazard.ini | 10 ++++ tools/MapEdit/platform.ini | 6 +++ .../spongebob project/spongebob project.dsp | 16 ++++++ 13 files changed, 142 insertions(+), 6 deletions(-) diff --git a/makefile.gaz b/makefile.gaz index 1047d4190..aa8c3de6e 100644 --- a/makefile.gaz +++ b/makefile.gaz @@ -124,7 +124,8 @@ platform_src := platform \ pclam \ pfishhk3 \ prbridge \ - pbaloon + pbaloon \ + ptrpdoor hazard_src := hazard \ hfalling \ @@ -144,7 +145,8 @@ hazard_src := hazard \ hrrock \ hflytrap \ hrweight \ - hrwheel + hrwheel \ + hpswitch fx_src := fx \ fxbaseanim \ diff --git a/source/hazard/hazard.cpp b/source/hazard/hazard.cpp index 5f7602d78..68971f72a 100644 --- a/source/hazard/hazard.cpp +++ b/source/hazard/hazard.cpp @@ -103,6 +103,10 @@ #include "hazard\hrwheel.h" #endif +#ifndef __HAZARD_HPSWITCH_H__ +#include "hazard\hpswitch.h" +#endif + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -126,6 +130,7 @@ CNpcHazard::NPC_HAZARD_UNIT_TYPE CNpcHazard::mapEditConvertTable[NPC_HAZARD_TYPE NPC_FLY_TRAP_HAZARD, NPC_RISING_WEIGHT_HAZARD, NPC_RISING_WEIGHT_WHEEL_HAZARD, + NPC_PRESSURE_SWITCH_HAZARD, }; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -246,6 +251,12 @@ CNpcHazard *CNpcHazard::Create(sThingHazard *ThisHazard) break; } + case NPC_PRESSURE_SWITCH_HAZARD: + { + hazard = new ("pressure switch hazard") CNpcPressureSwitchHazard; + break; + } + default: { hazard = NULL; diff --git a/source/hazard/hazard.h b/source/hazard/hazard.h index b87646a10..1c79423cb 100644 --- a/source/hazard/hazard.h +++ b/source/hazard/hazard.h @@ -54,6 +54,7 @@ public: NPC_FLY_TRAP_HAZARD, NPC_RISING_WEIGHT_HAZARD, NPC_RISING_WEIGHT_WHEEL_HAZARD, + NPC_PRESSURE_SWITCH_HAZARD, NPC_HAZARD_TYPE_MAX, }; diff --git a/source/level/level.cpp b/source/level/level.cpp index 9cf38ee17..d89cd4717 100644 --- a/source/level/level.cpp +++ b/source/level/level.cpp @@ -555,6 +555,7 @@ void CLevel::initThings(int _respawningLevel) CJellyfishGenerator::init(); CThingManager::initAllThings(); CThingManager::matchWheelsAndWeights(); + CThingManager::matchPressureSwitches(); } diff --git a/source/platform/platdata.cpp b/source/platform/platdata.cpp index f4f0a7134..1b0851bbc 100644 --- a/source/platform/platdata.cpp +++ b/source/platform/platdata.cpp @@ -395,6 +395,18 @@ CNpcPlatform::NPC_PLATFORM_DATA CNpcPlatform::m_data[NPC_PLATFORM_TYPE_MAX] = NPC_PLATFORM_TIMER_NONE, }, + { // NPC_TRAPDOOR_PLATFORM + 3, + 128, + true, + DAMAGE__NONE, + 0, + 4, + NPC_PLATFORM_INFINITE_LIFE, + 0, + NPC_PLATFORM_TIMER_NONE, + }, + { // NPC_PLAYER_BUBBLE_PLATFORM 3, 128, @@ -451,6 +463,7 @@ CNpcPlatform::NPC_PLATFORM_UNIT_TYPE CNpcPlatform::mapEditConvertTable[NPC_PLATF NPC_FISH_HOOK_3_PLATFORM, NPC_RISING_BRIDGE_PLATFORM, NPC_BALLOON_BRIDGE_PLATFORM, + NPC_TRAPDOOR_PLATFORM, NPC_PLAYER_BUBBLE_PLATFORM, NPC_CLAM_PLATFORM, }; diff --git a/source/platform/platform.cpp b/source/platform/platform.cpp index 6e0350be6..bc812bfff 100644 --- a/source/platform/platform.cpp +++ b/source/platform/platform.cpp @@ -155,6 +155,10 @@ #include "platform\pbaloon.h" #endif +#ifndef __PLATFORM_PTRPDOOR_H__ +#include "platform\ptrpdoor.h" +#endif + #include "fx\fx.h" #include "fx\fxjfish.h" @@ -364,6 +368,12 @@ CNpcPlatform *CNpcPlatform::Create(sThingPlatform *ThisPlatform) break; } + case NPC_TRAPDOOR_PLATFORM: + { + platform = new ("trapdoor platform") CNpcTrapdoorPlatform; + break; + } + default: { ASSERT( 0 ); @@ -1077,11 +1087,20 @@ int CNpcPlatform::getHeightFromPlatformAtPosition(int _x,int _y, int offsetX, in // Rotate backwards to find height at current position - int hypotenuse = ( ( top.vx - _x ) << 12 ) / rcos( angle ); + s16 cosVal = rcos( angle ); - int angleHeight = -( hypotenuse * rsin( angle ) ) >> 12; + if ( !cosVal ) + { + return( top.vy - _y ); + } + else + { + int hypotenuse = ( ( top.vx - _x ) << 12 ) / cosVal; - return( ( top.vy - _y ) + angleHeight ); + int angleHeight = -( hypotenuse * rsin( angle ) ) >> 12; + + return( ( top.vy - _y ) + angleHeight ); + } } } diff --git a/source/platform/platform.h b/source/platform/platform.h index 9774239e2..272c1932a 100644 --- a/source/platform/platform.h +++ b/source/platform/platform.h @@ -83,6 +83,7 @@ public: NPC_FISH_HOOK_3_PLATFORM, NPC_RISING_BRIDGE_PLATFORM, NPC_BALLOON_BRIDGE_PLATFORM, + NPC_TRAPDOOR_PLATFORM, NPC_PLAYER_BUBBLE_PLATFORM, NPC_CLAM_PLATFORM, NPC_PLATFORM_TYPE_MAX, @@ -108,6 +109,7 @@ public: void setGraphic( u8 graphicNum ); virtual void setWaypoints( sThingPlatform *ThisPlatform ); virtual void trigger() {;} + NPC_PLATFORM_UNIT_TYPE getType() {return( m_type );} static NPC_PLATFORM_UNIT_TYPE getTypeFromMapEdit( u16 newType ); static CNpcPlatform *Create(sThingPlatform *ThisPlatform); diff --git a/source/thing/thing.cpp b/source/thing/thing.cpp index ab795b86a..74c81c80b 100644 --- a/source/thing/thing.cpp +++ b/source/thing/thing.cpp @@ -43,6 +43,10 @@ #include "hazard\hrwheel.h" #endif +#ifndef __HAZARD_HPSWITCH_H__ +#include "hazard\hpswitch.h" +#endif + /* Std Lib ------- */ @@ -189,6 +193,53 @@ void CThingManager::initAllThings() } } +/*---------------------------------------------------------------------- + Function: + Purpose: + Params: + Returns: + ---------------------------------------------------------------------- */ + +void CThingManager::matchPressureSwitches() +{ + CNpcHazard *hazard; + + hazard = (CNpcHazard *) s_thingLists[CThing::TYPE_HAZARD]; + + while( hazard ) + { + if ( hazard->getType() == CNpcHazard::NPC_PRESSURE_SWITCH_HAZARD ) + { + CNpcPressureSwitchHazard *switchHazard = (CNpcPressureSwitchHazard *) hazard; + + DVECTOR triggerPos = switchHazard->getTriggerPos(); + + CNpcPlatform *platform; + + platform = (CNpcPlatform *) s_thingLists[CThing::TYPE_PLATFORM]; + + while( platform ) + { + if ( platform->getType() == CNpcPlatform::NPC_TRAPDOOR_PLATFORM ) + { + CNpcTrapdoorPlatform *trapdoor = (CNpcTrapdoorPlatform *) platform; + + DVECTOR testPos = trapdoor->getTriggerPos(); + + if ( testPos.vx == triggerPos.vx && testPos.vy == triggerPos.vy ) + { + switchHazard->linkToPlatform( trapdoor ); + } + } + + platform = (CNpcPlatform *) platform->m_nextListThing; + } + } + + hazard = (CNpcHazard *) hazard->m_nextListThing; + } +} + /*---------------------------------------------------------------------- Function: Purpose: diff --git a/source/thing/thing.h b/source/thing/thing.h index 24bc45c57..81334ff94 100644 --- a/source/thing/thing.h +++ b/source/thing/thing.h @@ -63,6 +63,7 @@ public: static CThing* checkCollisionAreaAgainstThings(CRECT *_area,int _type,int _continue); static void initCollision(); static void matchWheelsAndWeights(); + static void matchPressureSwitches(); static sBBox &getRenderBBox() {return(m_RenderBBox);} static sBBox &getThinkBBox() {return(m_ThinkBBox);} diff --git a/tools/Data/bin/MkLevel.ini b/tools/Data/bin/MkLevel.ini index 239666acb..dde756062 100644 --- a/tools/Data/bin/MkLevel.ini +++ b/tools/Data/bin/MkLevel.ini @@ -112,6 +112,8 @@ Retracting=6 RollingOildrumPlatform=24 RisingBridge=27 BalloonBridge=28 +TrapdoorLeft=29 +TrapdoorRight=29 ################################################ # Triggers @@ -152,4 +154,5 @@ Fireball=13 BouncingRock=12 FlyTrap=15 RisingWeight=16 -RisingWeightWheel=17 \ No newline at end of file +RisingWeightWheel=17 +PressureSwitch=18 \ No newline at end of file diff --git a/tools/MapEdit/Hazard.ini b/tools/MapEdit/Hazard.ini index 52b7b8129..4523133d4 100644 --- a/tools/MapEdit/Hazard.ini +++ b/tools/MapEdit/Hazard.ini @@ -219,3 +219,13 @@ Collision=0 Health=0 AttackStrength=0 Respawn=2 + +[PressureSwitch] +Gfx=..\..\graphics\hazards\pressureswitch\pressureswitch.gin +Waypoints=1 +Speed=0 +TurnRate=0 +Collision=0 +Health=0 +AttackStrength=0 +Respawn=2 diff --git a/tools/MapEdit/platform.ini b/tools/MapEdit/platform.ini index a95480c28..4c99373fd 100644 --- a/tools/MapEdit/platform.ini +++ b/tools/MapEdit/platform.ini @@ -111,3 +111,9 @@ Gfx=..\..\Graphics\platforms\seesaw\seesaw_wooden.gin [BalloonBridge] Gfx=..\..\Graphics\platforms\seesaw\seesaw_wooden.gin + +[TrapdoorLeft] +Gfx=..\..\Graphics\platforms\trapdoor_wooden\trapdoor_woodenl.gin + +[TrapdoorRight] +Gfx=..\..\Graphics\platforms\trapdoor_wooden\trapdoor_woodenr.gin \ No newline at end of file diff --git a/users/paul/spongebob project/spongebob project.dsp b/users/paul/spongebob project/spongebob project.dsp index aa6b3ea1f..e3d5a2156 100644 --- a/users/paul/spongebob project/spongebob project.dsp +++ b/users/paul/spongebob project/spongebob project.dsp @@ -917,6 +917,14 @@ SOURCE=..\..\..\source\hazard\hpendulm.h # End Source File # Begin Source File +SOURCE=..\..\..\source\hazard\hpswitch.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\source\hazard\hpswitch.h +# End Source File +# Begin Source File + SOURCE=..\..\..\source\hazard\hrrock.cpp # End Source File # Begin Source File @@ -1451,6 +1459,14 @@ SOURCE=..\..\..\source\platform\pseesaw.cpp SOURCE=..\..\..\source\platform\pseesaw.h # End Source File +# Begin Source File + +SOURCE=..\..\..\source\platform\ptrpdoor.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\source\platform\ptrpdoor.h +# End Source File # End Group # Begin Group "player"