Skip to content

Commit

Permalink
fix(zc): oddities with pushblocks and pits/water
Browse files Browse the repository at this point in the history
  • Loading branch information
EmilyV99 committed Sep 19, 2023
1 parent dd82637 commit 54f0de9
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 25 deletions.
1 change: 1 addition & 0 deletions src/sprite.h
Expand Up @@ -285,6 +285,7 @@ class movingblock : public sprite
void push_new(zfix bx,zfix by,int32_t d,int32_t f,zfix spd);
bool check_hole() const;
bool check_trig() const;
bool active() const;
virtual bool animate(int32_t index);
virtual void draw(BITMAP *dest);
bool draw(BITMAP *dest, int layer);
Expand Down
6 changes: 3 additions & 3 deletions src/zc/ffscript.cpp
Expand Up @@ -9724,15 +9724,15 @@ int32_t get_register(const int32_t arg)
break;

case PUSHBLOCKX:
ret = blockmoving ? int32_t(mblock2.x)*10000 : -10000;
ret = mblock2.active() ? int32_t(mblock2.x)*10000 : -10000;
break;

case PUSHBLOCKY:
ret = blockmoving ? int32_t(mblock2.y)*10000 : -10000;
ret = mblock2.active() ? int32_t(mblock2.y)*10000 : -10000;
break;

case PUSHBLOCKLAYER:
ret = blockmoving ? int32_t(mblock2.blockLayer)*10000 : -10000;
ret = mblock2.active() ? int32_t(mblock2.blockLayer)*10000 : -10000;
break;

case PUSHBLOCKCOMBO:
Expand Down
10 changes: 5 additions & 5 deletions src/zc/hero.cpp
Expand Up @@ -17186,7 +17186,7 @@ bool HeroClass::scr_walkflag(int dx,int dy,int d2,bool kb)
if(blockpath && dy<80) //Blocked top parts of rooms
return true;

if(blockmoving && mblock2.hit(dx,dy,0,1,1,1))
if(mblock2.active() && mblock2.hit(dx,dy,0,1,1,1))
return true;
//collide_object handled in scr_canmove

Expand Down Expand Up @@ -19275,7 +19275,7 @@ HeroClass::WalkflagInfo HeroClass::walkflag(int32_t wx,int32_t wy,int32_t cnt,by
return ret;
}

if(blockmoving && mblock2.hit(wx,wy,0,1,1,1))
if(mblock2.active() && mblock2.hit(wx,wy,0,1,1,1))
{
ret.setUnwalkable(true);
return ret;
Expand Down Expand Up @@ -19777,13 +19777,13 @@ HeroClass::WalkflagInfo HeroClass::walkflag(int32_t wx,int32_t wy,int32_t cnt,by
HeroClass::WalkflagInfo HeroClass::walkflagMBlock(int32_t wx,int32_t wy)
{
HeroClass::WalkflagInfo ret;
if (!blockmoving) //Without this, weird swimming behaviors happen.
if (!mblock2.active()) //Without this, weird swimming behaviors happen.
{
ret.setFlags(~1);
ret.setHopDir(-1);
}
if(toogam) return ret;
if (blockmoving)
if (mblock2.active())
ret.setUnwalkable(mblock2.hit(wx,wy,0,1,1,1));
if (collide_object(wx, wy,1, 1))
ret.setUnwalkable(true);
Expand Down Expand Up @@ -20176,7 +20176,7 @@ void HeroClass::checkpushblock()
++usecounts[itemid];

// for(int32_t i=0; i<1; i++)
if(!blockmoving)
if(!mblock2.active())
{
if(changeflag)
{
Expand Down
23 changes: 11 additions & 12 deletions src/zc/zc_sprite.cpp
Expand Up @@ -166,6 +166,7 @@ void sprite::check_conveyor()
void movingblock::clear()
{
trigger = bhole = force_many = no_icy = new_block = false;
fallclk = drownclk = 0;
endx=x=endy=y=0;
dir=-1;
oldflag=0;
Expand Down Expand Up @@ -238,7 +239,6 @@ void movingblock::push(zfix bx,zfix by,int32_t d2,int32_t f)
FFCore.clear_combo_script(blockLayer, combopos);
putcombo(scrollbuf,x,y,*di,*ci);
clk=32;
blockmoving=true;
if(!get_qr(qr_MOVINGBLOCK_FAKE_SOLID))
setSolid(true);
solid_update(false);
Expand Down Expand Up @@ -289,7 +289,6 @@ void movingblock::push_new(zfix bx,zfix by,int d2,int f,zfix spd)
FFCore.clear_combo_script(blockLayer, combopos);
putcombo(scrollbuf,x,y,*di,*ci);
clk=32;
blockmoving=true;
if(!get_qr(qr_MOVINGBLOCK_FAKE_SOLID))
setSolid(true);
solid_update(false);
Expand Down Expand Up @@ -367,6 +366,11 @@ bool movingblock::check_trig() const
return false;
}

bool movingblock::active() const
{
return clk > 0 || fallclk || drownclk;
}

bool movingblock::animate(int32_t)
{
mapscr* m = FFCore.tempScreens[blockLayer];
Expand All @@ -377,25 +381,21 @@ bool movingblock::animate(int32_t)
{
if(fallclk == PITFALL_FALL_FRAMES)
sfx(combobuf[fallCombo].attribytes[0], pan(x.getInt()));
if(!--fallclk)
{
blockmoving=false;
}
clk = 0;
solid_update(false);
if(!--fallclk)
clear();
return false;
}
if(drownclk)
{
//if(drownclk == WATER_DROWN_FRAMES)
//sfx(combobuf[drownCombo].attribytes[0], pan(x.getInt()));
//!TODO: Drown SFX
if(!--drownclk)
{
blockmoving=false;
}
clk = 0;
solid_update(false);
if(!--drownclk)
clear();
return false;
}
if(clk<=0)
Expand Down Expand Up @@ -611,7 +611,6 @@ bool movingblock::animate(int32_t)
x = endx;
y = endy;
trigger = false; bhole = false;
blockmoving=false;

int f1 = m->sflag[combopos];
int f2 = MAPCOMBOFLAG2(blockLayer-1,x,y);
Expand Down Expand Up @@ -808,7 +807,6 @@ bool movingblock::animate(int32_t)
else
{
trigger = false; bhole = false;
blockmoving=false;

int32_t f1 = m->sflag[combopos];
int32_t f2 = MAPCOMBOFLAG2(blockLayer-1,x,y);
Expand Down Expand Up @@ -1034,6 +1032,7 @@ bool movingblock::animate(int32_t)
{
do_trigger_combo(blockLayer, combopos);
}
clear();
}
return false;
}
7 changes: 3 additions & 4 deletions src/zc/zelda.cpp
Expand Up @@ -1107,7 +1107,6 @@ void Z_scripterrlog(const char * const format,...)
}
}

bool blockmoving;
#include "sprite.h"
movingblock mblock2; //mblock[4]?
portal mirror_portal;
Expand Down Expand Up @@ -1219,7 +1218,7 @@ void ALLOFF(bool messagesToo, bool decorationsToo, bool force)
guygridffc[i]=0;

sle_clk=0;
blockmoving=false;
mblock2.clear();
fairy_cnt=0;

if(usebombpal)
Expand Down Expand Up @@ -1766,7 +1765,7 @@ int32_t init_game()
Hero.reset_hookshot();
Hero.reset_ladder();
linkedmsgclk=0;
blockmoving=false;
mblock2.clear();
add_asparkle=0;
add_bsparkle=0;
add_df1asparkle=false;
Expand Down Expand Up @@ -2374,7 +2373,7 @@ int32_t cont_game()
Hero.reset_hookshot();
Hero.reset_ladder();
linkedmsgclk=0;
blockmoving=0;
mblock2.clear();
add_asparkle=0;
add_bsparkle=0;
add_df1asparkle=false;
Expand Down
1 change: 0 additions & 1 deletion src/zc/zelda.h
Expand Up @@ -354,7 +354,6 @@ extern dword fps_secs;
extern float avgfps;

extern bool cheats_execute_goto, cheats_execute_light;
extern bool blockmoving;
extern bool Throttlefps, MenuOpen, ClickToFreeze, Paused, Saving, Advance, ShowFPS, Showpal,
Playing, FrameSkip, TransLayers, clearConsoleOnLoad, clearConsoleOnReload, disableClickToFreeze,
SaveDragResize, DragAspect, SaveWinPos, scaleForceInteger, stretchGame;
Expand Down

0 comments on commit 54f0de9

Please sign in to comment.