Commit 721eadb9 authored by gerstrong@gmail.com's avatar gerstrong@gmail.com

More python support

parent 39c4a71e
......@@ -6,12 +6,15 @@
*/
#include "CInventory.h"
#include "engine/core/CBehaviorEngine.h"
#include "graphics/GsGraphics.h"
#include <base/video/CVideoDriver.h>
#include <base/CInput.h>
#include "graphics/effects/CScrollEffect.h"
#include "fileio/KeenFiles.h"
#include <base/GsPython.h>
CInventory::CInventory(const int playerIdx,
const int spriteVar) :
......@@ -20,18 +23,48 @@ m_HUD(Item.m_points, Item.m_lifes, Item.m_bullets,
{
reset();
auto Episode = gBehaviorEngine.getEpisode();
auto ep = gBehaviorEngine.getEpisode();
if(Episode >= 4)
if(ep >= 4)
{
const Difficulty difficulty = gBehaviorEngine.mDifficulty;
Item.m_bullets = 8;
if( difficulty > EASY )
Item.m_bullets = 5;
{
Item.m_bullets = 5;
}
mp_StatusScreen.reset(new CStatusScreenGalaxy(Item));
}
#if USE_PYTHON3
auto pModule = gPython.loadModule( "constants", gKeenFiles.gameDir );
if (pModule != nullptr)
{
int startBullets = 0;
bool ok;
ok = loadIntegerFunc(pModule, "getStartWithNumBullets", startBullets);
if(ok)
{
Item.m_bullets = startBullets;
}
bool usePogo;
ok = loadBooleanFunc(pModule, "mayUsePogo", usePogo);
if(ok)
{
Item.m_special.mCanPogo = usePogo;
}
}
#endif
m_HUD.sync();
}
......
......@@ -26,19 +26,19 @@
namespace galaxy {
const int MAX_JUMPHEIGHT = 10;
const int MIN_JUMPHEIGHT = 5;
//const int MAX_JUMPHEIGHT = 10;
//const int MIN_JUMPHEIGHT = 5;
const int MAX_POGOHEIGHT = 20;
const int MIN_POGOHEIGHT = 5;
const int POGO_SLOWDOWN = 4;
//const int MAX_POGOHEIGHT = 20;
//const int MIN_POGOHEIGHT = 5;
//const int POGO_SLOWDOWN = 4;
const int POGO_START_INERTIA = -125; // 48 In K5 Disassemble
const int POGO_START_INERTIA_VERT = -100;
const int POGO_START_INERTIA_MAX_VERT = -168;
const int POGO_START_INERTIA_IMPOSSIBLE_VERT = -180;
const int POGO_INERTIA_HOR_MAX = 64;
const int POGO_INERTIA_HOR_REACTION = 2;
constexpr int POGO_START_INERTIA = -125; // 48 In K5 Disassemble
//const int POGO_START_INERTIA_VERT = -100;
//const int POGO_START_INERTIA_MAX_VERT = -168;
constexpr int POGO_START_INERTIA_IMPOSSIBLE_VERT = -180;
//const int POGO_INERTIA_HOR_MAX = 64;
//const int POGO_INERTIA_HOR_REACTION = 2;
const int FIRE_RECHARGE_TIME = 5;
......@@ -273,27 +273,30 @@ void CPlayerLevel::processRunning()
return;
}
if (mActionState.pogoIsPressed && !mActionState.pogoWasPressed)
{
mActionState.pogoWasPressed = true;
// If you pressed run, perform a long jump
if(mPlaycontrol[PA_RUN])
{
xinertia = xDirection * 32;
}
else
if(m_Inventory.Item.m_special.mCanPogo)
{
if (mActionState.pogoIsPressed && !mActionState.pogoWasPressed)
{
xinertia = xDirection * 16;
}
mActionState.pogoWasPressed = true;
yinertia = evalVertPogoInertia();
// nextX = 0;
mActionState.jumpTimer = 24;
playSound( SOUND_KEEN_POGO );
setAction(A_KEEN_POGO_START);
return;
}
// If you pressed run, perform a long jump
if(mPlaycontrol[PA_RUN])
{
xinertia = xDirection * 32;
}
else
{
xinertia = xDirection * 16;
}
yinertia = evalVertPogoInertia();
// nextX = 0;
mActionState.jumpTimer = 24;
playSound( SOUND_KEEN_POGO );
setAction(A_KEEN_POGO_START);
return;
}
}
if (verifyForFalling())
......@@ -382,17 +385,20 @@ void CPlayerLevel::handleInputOnGround()
return;
}
if( mActionState.pogoIsPressed && !mActionState.pogoWasPressed)
{
mActionState.pogoWasPressed = true;
xinertia = 0;
yinertia = evalVertPogoInertia();
setAction(A_KEEN_POGO_START);
playSound( SOUND_KEEN_POGO );
nextY = 0;
mActionState.jumpTimer = 24;
return;
}
if(m_Inventory.Item.m_special.mCanPogo)
{
if( mActionState.pogoIsPressed && !mActionState.pogoWasPressed)
{
mActionState.pogoWasPressed = true;
xinertia = 0;
yinertia = evalVertPogoInertia();
setAction(A_KEEN_POGO_START);
playSound( SOUND_KEEN_POGO );
nextY = 0;
mActionState.jumpTimer = 24;
return;
}
}
// He could duck or use the pole
if( py > 0 )
......@@ -1056,18 +1062,21 @@ void CPlayerLevel::processPogoCommon()
// Houston, we've landed!
if(blockedd)
{
//yinertia = 0; // Not sure if that's correct
if (mActionState.jumpTimer == 0)
{
yinertia = evalVertPogoInertia();
playSound( SOUND_KEEN_POGO );
mActionState.jumpTimer = 24;
setAction(A_KEEN_POGO_UP);
}
}
if(m_Inventory.Item.m_special.mCanPogo)
{
if(blockedd)
{
//yinertia = 0; // Not sure if that's correct
if (mActionState.jumpTimer == 0)
{
yinertia = evalVertPogoInertia();
playSound( SOUND_KEEN_POGO );
mActionState.jumpTimer = 24;
setAction(A_KEEN_POGO_UP);
}
}
}
// Let's see if Keen breaks the fuse
if(mpMap->mFuseInLevel)
{
......@@ -1387,13 +1396,16 @@ void CPlayerLevel::processJumping()
moveXDir(xinertia);
if (mActionState.pogoIsPressed && !mActionState.pogoWasPressed)
{
mActionState.pogoWasPressed = true;
setAction(A_KEEN_POGO_UP);
mActionState.jumpTimer = 0;
return;
}
if(m_Inventory.Item.m_special.mCanPogo)
{
if (mActionState.pogoIsPressed && !mActionState.pogoWasPressed)
{
mActionState.pogoWasPressed = true;
setAction(A_KEEN_POGO_UP);
mActionState.jumpTimer = 0;
return;
}
}
if (mPlaycontrol[PA_Y] < 0)
{
......@@ -2578,19 +2590,23 @@ void CPlayerLevel::processFalling()
return;
}
/// While falling Keen could switch to pogo again anytime
// but first the player must release the pogo button
if( !mPlaycontrol[PA_POGO] )
m_pogotoggle = false;
if(m_Inventory.Item.m_special.mCanPogo)
{
// Now we can check if player wants to use it again
if( !m_pogotoggle && mPlaycontrol[PA_POGO] )
{
m_jumpheight = 0;
yinertia = 0;
setAction(A_KEEN_POGO_START);
m_pogotoggle = true;
}
/// While falling Keen could switch to pogo again anytime
// but first the player must release the pogo button
if( !mPlaycontrol[PA_POGO] )
m_pogotoggle = false;
// Now we can check if player wants to use it again
if( !m_pogotoggle && mPlaycontrol[PA_POGO] )
{
m_jumpheight = 0;
yinertia = 0;
setAction(A_KEEN_POGO_START);
m_pogotoggle = true;
}
}
// Check if keen should stick to the pole
if( mPlaycontrol[PA_Y] < 0 )
......
......@@ -107,7 +107,26 @@ void CSpriteItem::getTouchedBy(CSpriteObject &theObject)
newanimsprite = 231;
gSound.playSound( SOUND_GET_CARD );
}
// Enable pogo if some script would like that
#if USE_PYTHON3
auto pModule = gPython.loadModule( "constants", gKeenFiles.gameDir );
if (pModule != nullptr)
{
int value = 0;
const auto ok = loadIntegerFunc(pModule, "enablePogo", value, m_basesprite);
if(ok)
{
if(value==1)
{
Item.m_special.mCanPogo = true;
}
}
}
#endif
// Now add the stuff to the inventory
if(ep == 5)
......
......@@ -26,18 +26,11 @@ void stItemGalaxy::reset()
const int ep = gBehaviorEngine.getEpisode();
if(ep == 4)
{
m_special.elders = 0;
m_special.swimsuit = 0;
}
else if(ep == 6)
{
// k6demo starts with possesion of the hook.
m_special.hook = gBehaviorEngine.isDemo() ? 1 : 0;
m_special.sandwich = 0;
m_special.rocketKeycard = 0;
}
m_special.elders = 0;
m_special.swimsuit = 0;
m_special.hook = gBehaviorEngine.isDemo() ? 1 : 0;
m_special.sandwich = 0;
m_special.rocketKeycard = 0;
fuse_levels_completed = 0;
}
......
......@@ -16,10 +16,10 @@
struct stItemGalaxy
{
signed char m_lifes;
unsigned long m_points;
unsigned long m_lifeAt;
int m_drops;
signed char m_lifes;
unsigned long m_points;
unsigned long m_lifeAt;
int m_drops;
int m_bullets;
struct
......@@ -49,6 +49,9 @@ struct stItemGalaxy
unsigned char hook = 0;
unsigned char rocketKeycard = 0;
// In all galaxy games Keen can use the pogo. Some mods might want to disable this.
bool mCanPogo = true;
} m_special;
std::string mLevelName;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment