From 6e16891116f202016e19553613d406efb8ef7085 Mon Sep 17 00:00:00 2001 From: Paul Date: Tue, 29 May 2001 18:22:49 +0000 Subject: [PATCH] --- source/pickups/pickup.cpp | 49 +++++++++++++++++++++++++-- source/pickups/pickup.h | 6 ++++ source/player/player.cpp | 71 +++++++++++++++++++++++++++------------ source/player/player.h | 6 ++-- 4 files changed, 106 insertions(+), 26 deletions(-) diff --git a/source/pickups/pickup.cpp b/source/pickups/pickup.cpp index 1f86d564f..1e85e56bd 100644 --- a/source/pickups/pickup.cpp +++ b/source/pickups/pickup.cpp @@ -281,6 +281,42 @@ void CBaseRespawningPickup::collect(class CPlayer *_player) +/*---------------------------------------------------------------------- + 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; + } +} + + /*---------------------------------------------------------------------- Function: Purpose: @@ -292,9 +328,18 @@ void CBaseWeaponPickup::collidedWith(CThing *_thisThing) switch(_thisThing->getThingType()) { case TYPE_PLAYER: - if(((CPlayer*)_thisThing)->tryingToPickupWeapon()) { - collect((CPlayer*)_thisThing); + CPlayer *player; + player=(CPlayer*)_thisThing; + if(player->tryingToManuallyPickupWeapon()|| + (!m_dontAutoPickUpUntilPlayerMovesOffMe&&player->tryingToAutomaticallyPickupWeapon())) + { + collect(player); + } + else + { + m_collidedWithPlayer=true; + } } break; diff --git a/source/pickups/pickup.h b/source/pickups/pickup.h index 3b5d60837..be2f48ec3 100644 --- a/source/pickups/pickup.h +++ b/source/pickups/pickup.h @@ -113,8 +113,14 @@ private: class CBaseWeaponPickup : public CBasePickup { +public: + virtual void init(); + virtual void think(int _frames); + protected: virtual void collidedWith(CThing *_thisThing); + int m_dontAutoPickUpUntilPlayerMovesOffMe; + int m_collidedWithPlayer; }; diff --git a/source/player/player.cpp b/source/player/player.cpp index 44119f001..3c8ede813 100644 --- a/source/player/player.cpp +++ b/source/player/player.cpp @@ -81,6 +81,10 @@ #include "game\game.h" #endif +#ifndef __PICKUPS_PICKUP_H__ +#include "pickups\pickup.h" +#endif + /* Std Lib ------- */ @@ -675,9 +679,6 @@ void CPlayer::shutdown() static int oldmode=-1; int newmode=-1; -int scmax=160; -int scspeed=5; - void CPlayer::think(int _frames) { int i; @@ -741,31 +742,55 @@ if(newmode!=-1) } } - m_tryingToPickupWeapon=false; + m_tryingToManuallyPickupWeapon=false; + m_tryingToAutomaticallyPickupWeapon=false; for(i=0;i<_frames;i++) { - // Think updatePadInput(); - if(!m_tryingToPickupWeapon) + + // Weapon collect/drop/swap stuff.. + if(m_currentMode==PLAYER_MODE_BASICUNARMED|| + m_currentMode==PLAYER_MODE_FULLUNARMED) { - if(m_currentMode==PLAYER_MODE_BASICUNARMED|| - m_currentMode==PLAYER_MODE_FULLUNARMED) + // Always trying to pickup weapon if unarmed... means that when SB walks + // over an item whilst unarmed, he automatically picks it up + m_tryingToAutomaticallyPickupWeapon=true; + } + if(getPadInputDown()&PI_WEAPONCHANGE) + { + // Trying to pick up a weapon + m_tryingToManuallyPickupWeapon=true; + + // If already armed then drop current weapon + if(m_currentMode!=PLAYER_MODE_BASICUNARMED&& + m_currentMode!=PLAYER_MODE_FULLUNARMED&& + m_currentMode!=PLAYER_MODE_DEAD) { - // Always trying to pickup weapon if unarmed... means that when SB walks - // over an item whilst unarmed, he automatically picks it up - m_tryingToPickupWeapon=true; - } - else if(getPadInputDown()&PI_WEAPONCHANGE) - { - if(!m_tryingToPickupWeapon&& - m_currentMode!=PLAYER_MODE_BASICUNARMED&& - m_currentMode!=PLAYER_MODE_FULLUNARMED&& - m_currentMode!=PLAYER_MODE_DEAD) + static const int s_pickupsToDrop[NUM_PLAYERMODES]= { - // Drop current weapon - setMode(PLAYER_MODE_FULLUNARMED); + -1, // PLAYER_MODE_BASICUNARMED, + -1, // PLAYER_MODE_FULLUNARMED, + -1, // PLAYER_MODE_BALLOON, + PICKUP__BUBBLE_WAND, // PLAYER_MODE_BUBBLE_MIXTURE, + PICKUP__NET, // PLAYER_MODE_NET, + PICKUP__CORAL_BLOWER, // PLAYER_MODE_CORALBLOWER, + PICKUP__JELLY_LAUNCHER, // PLAYER_MODE_JELLY_LAUNCHER, + -1, // PLAYER_MODE_DEAD, + -1, // PLAYER_MODE_FLY, + }; + + int pickupToDrop; + pickupToDrop=s_pickupsToDrop[m_currentMode]; + if(pickupToDrop!=-1) + { + DVECTOR pickupPos; + CBasePickup *pickup; + pickupPos.vx=Pos.vx; + pickupPos.vy=Pos.vy-30; + pickup=createPickup((PICKUP_TYPE)pickupToDrop,&pickupPos); + pickup->setPos(&pickupPos); } - m_tryingToPickupWeapon=true; + setMode(PLAYER_MODE_FULLUNARMED); } } @@ -1651,6 +1676,8 @@ void CPlayer::respawn() m_ledgeLookAhead=m_lastLedgeLookAhead=0; m_ledgeLookOffset=0; m_ledgeLookTimer=0; + m_tryingToManuallyPickupWeapon=false; + m_tryingToAutomaticallyPickupWeapon=false; m_squeakyBootsTimer=0; m_invincibilityRingTimer=0; @@ -1828,7 +1855,7 @@ void CPlayer::inSoakUpState() _thing must point to the thing that caused the damage Returns: ---------------------------------------------------------------------- */ -#if defined(__USER_daveo__) +#if defined(__USER_daveo__) || defined(__USER_paul__) int invincibleSponge=true; // NB: This is for debugging purposes only so don't try and use it for a permenant cheat mode.. #else int invincibleSponge=false; // NB: This is for debugging purposes only so don't try and use it for a permenant cheat mode.. diff --git a/source/player/player.h b/source/player/player.h index 82ee3e985..b66be55ce 100644 --- a/source/player/player.h +++ b/source/player/player.h @@ -260,7 +260,8 @@ public: void setPlayerPos(DVECTOR *_pos) {Pos=*_pos;} PLAYERINPUT getPadInputHeld() {return m_padInput;} PLAYERINPUT getPadInputDown() {return m_padInputDown;} - int tryingToPickupWeapon() {return m_tryingToPickupWeapon;} + int tryingToManuallyPickupWeapon() {return m_tryingToManuallyPickupWeapon;} + int tryingToAutomaticallyPickupWeapon() {return m_tryingToAutomaticallyPickupWeapon;} void inSoakUpState(); void takeDamage(DAMAGE_TYPE _damage,REACT_DIRECTION _reactDirection=REACT__UP,CThing *_thing=NULL); @@ -338,7 +339,8 @@ private: PLAYERINPUT m_padInput; // Controls that are being held down PLAYERINPUT m_lastPadInput; // Last frames controls PLAYERINPUT m_padInputDown; // Controls that were pressed this frame - int m_tryingToPickupWeapon; + int m_tryingToManuallyPickupWeapon; + int m_tryingToAutomaticallyPickupWeapon; // Various info about the current map