Skip to content

Commit 64d42a1

Browse files
committed
Some reworking of bombs
1 parent b312641 commit 64d42a1

File tree

13 files changed

+354
-247
lines changed

13 files changed

+354
-247
lines changed

src/base/zdefs.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ enum {ENC_METHOD_192B104=0, ENC_METHOD_192B105, ENC_METHOD_192B185, ENC_METHOD_2
294294
#define V_SFX 8
295295
#define V_FAVORITES 3
296296

297-
#define V_COMPATRULE 42
297+
#define V_COMPATRULE 43
298298
#define V_ZINFO 3
299299

300300
//= V_SHOPS is under V_MISC
@@ -1119,7 +1119,7 @@ enum
11191119
qr_OLD_FFC_FUNCTIONALITY = 50*8, qr_OLD_SHALLOW_SFX, qr_BUGGED_LAYERED_FLAGS, qr_HARDCODED_FFC_BUSH_DROPS,
11201120
qr_POUNDLAYERS1AND2, qr_MOVINGBLOCK_FAKE_SOLID, qr_NEW_HERO_MOVEMENT2, qr_CARRYABLE_NO_ACROSS_SCREEN,
11211121
//51
1122-
qr_NO_SCROLL_WHILE_CARRYING, qr_HELD_BOMBS_EXPLODE, qr_BROKEN_MOVING_BOMBS,
1122+
qr_NO_SCROLL_WHILE_CARRYING, qr_HELD_BOMBS_EXPLODE, qr_BROKEN_MOVING_BOMBS, qr_OLD_BOMB_HITBOXES,
11231123
//60
11241124
//70
11251125

src/dialog/itemeditor.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,9 @@ void loadinfo(ItemNameInfo * inf, itemdata const& ref)
411411
inf->misc[1] = "Max. On Screen:";
412412
inf->misc[2] = "Damage to Player:";
413413
_SET(misc[3], "Lift Level", "If 0, the weapon is not liftable. Otherwise, liftable using Lift Gloves of at least this level.");
414-
_SET(misc[4], "Lift Height", "The Z height above the player's head to lift the weapon.");
414+
_SET(misc[4], "Lift Time", "The time, in frames, to lift the weapon above the player's head.");
415+
_SET(misc[5], "Lift Height", "The Z height above the player's head to lift the weapon.");
416+
_SET(misc[6], "Boom Radius", "If 0, uses a classic boxy hitbox- otherwise uses a circular radius of this many pixels." + QRHINT({qr_OLD_BOMB_HITBOXES}));
415417
inf->flag[1] = "Explosion Hurts Player";
416418
_SET(flag[2], "Stops Movement on Landing", "If the weapon lands due to gravity, it's step will be set to 0.");
417419
_SET(flag[3], "Auto-Lift", "If the player owns a Lift Glove, place the bomb directly in the player's hands.");
@@ -429,6 +431,7 @@ void loadinfo(ItemNameInfo * inf, itemdata const& ref)
429431
_SET(misc[3], "Lift Level", "If 0, the weapon is not liftable. Otherwise, liftable using Lift Gloves of at least this level.");
430432
_SET(misc[4], "Lift Time", "The time, in frames, to lift the weapon above the player's head.");
431433
_SET(misc[5], "Lift Height", "The Z height above the player's head to lift the weapon.");
434+
_SET(misc[6], "Boom Radius", "If 0, uses a classic boxy hitbox- otherwise uses a circular radius of this many pixels." + QRHINT({qr_OLD_BOMB_HITBOXES}));
432435
inf->flag[0] = "Use 1.92 Timing";
433436
inf->flag[1] = "Explosion Hurts Player";
434437
_SET(flag[2], "Stops Movement on Landing", "If the weapon lands due to gravity, it's step will be set to 0.");

src/dialog/quest_rules.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -882,7 +882,10 @@ static GUI::ListData compatRulesList
882882
" Note that you can access the real engine uid with ->HitBy[HIT_BY_(thing)_ENGINE_UID] regardless of this rule."},
883883
{ "Broken Moving && Air Bombs", qr_BROKEN_MOVING_BOMBS,
884884
"If enabled, bombs exploding while moving will behave oddly and broken, and bomb explosions"
885-
" will continue obeying gravity." }
885+
" will continue obeying gravity." },
886+
{ "Old Bomb Hitboxes", qr_OLD_BOMB_HITBOXES,
887+
"If enabled, the outer ring of bombs' hitboxes will not count for triggering combos/secrets,"
888+
" and giving bombs custom radii will not work."}
886889
};
887890

888891
static GUI::ListData enemiesRulesList

src/items.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,12 @@ void item::draw(BITMAP *dest)
315315
}
316316
}
317317

318+
void item::draw_hitbox()
319+
{
320+
if(subscreenItem) return;
321+
sprite::draw_hitbox();
322+
}
323+
318324
item::item(zfix X,zfix Y,zfix Z,int32_t i,int32_t p,int32_t c, bool isDummy) : sprite()
319325
{
320326
x=X;
@@ -447,6 +453,7 @@ void putitem(BITMAP *dest,int32_t x,int32_t y,int32_t item_id)
447453
{
448454
item temp((zfix)x,(zfix)y,(zfix)0,item_id,0,0);
449455
temp.yofs=0;
456+
temp.hide_hitbox = true;
450457

451458
if ( itemsbuf[item_id].overrideFLAGS > 0 ) {
452459
temp.extend = 3;
@@ -573,6 +580,7 @@ void putitem2(BITMAP *dest,int32_t x,int32_t y,int32_t item_id, int32_t &aclk, i
573580
temp.yofs=0;
574581
temp.aclk=aclk;
575582
temp.aframe=aframe;
583+
temp.hide_hitbox = true;
576584

577585
if(flash)
578586
{

src/items.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ class item : public sprite
5555
virtual int32_t run_script(int32_t mode);
5656
#endif
5757
virtual ALLEGRO_COLOR hitboxColor(byte opacity = 255) const;
58+
virtual void draw_hitbox();
5859
void set_forcegrab(bool val)
5960
{
6061
if(force_grab && !val)

src/qst.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3746,6 +3746,8 @@ int32_t readrules(PACKFILE *f, zquestheader *Header, bool keepdata)
37463746
set_bit(quest_rules,qr_BROKENHITBY,1);
37473747
if(compatrule_version < 42)
37483748
set_bit(quest_rules,qr_BROKEN_MOVING_BOMBS,1);
3749+
if(compatrule_version < 43)
3750+
set_bit(quest_rules,qr_OLD_BOMB_HITBOXES,1);
37493751

37503752
set_bit(quest_rules,qr_ANIMATECUSTOMWEAPONS,0);
37513753
if (s_version < 16)

src/sprite.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ sprite::sprite(): solid_object()
178178
spr_death_anim_frm = 0;
179179
spr_spawn_anim_clk = 0;
180180
spr_spawn_anim_frm = 0;
181+
hide_hitbox = false;
181182
}
182183

183184
sprite::sprite(sprite const & other):
@@ -1583,14 +1584,9 @@ void sprite::draw(BITMAP* dest)
15831584
}
15841585
}
15851586

1586-
#ifndef IS_ZQUEST
15871587
if(show_hitboxes)
1588-
{
1589-
start_info_bmp();
1590-
al_draw_rectangle(x+hxofs,y+playing_field_offset+hyofs-(z+zofs)-fakez,x+hxofs+hxsz,(y+playing_field_offset+hyofs+hysz-(z+zofs)-fakez),hitboxColor(info_opacity),1);
1591-
end_info_bmp();
1592-
}
1593-
#endif
1588+
draw_hitbox();
1589+
15941590
if ( sprBMP2 )
15951591
{
15961592
//if there is still somehow data in the scaling bitmap
@@ -1600,6 +1596,16 @@ void sprite::draw(BITMAP* dest)
16001596
yofs = tyoffs;
16011597
}
16021598

1599+
void sprite::draw_hitbox()
1600+
{
1601+
if(hide_hitbox) return;
1602+
#ifndef IS_ZQUEST
1603+
start_info_bmp();
1604+
al_draw_rectangle(x+hxofs,y+playing_field_offset+hyofs-(z+zofs)-fakez,x+hxofs+hxsz,(y+playing_field_offset+hyofs+hysz-(z+zofs)-fakez),hitboxColor(info_opacity),1);
1605+
end_info_bmp();
1606+
#endif
1607+
}
1608+
16031609

16041610
//Z1 bosses draw tiles from guys.cpp, direct to the 'dest'
16051611
void sprite::drawzcboss(BITMAP* dest)
@@ -1958,14 +1964,8 @@ void sprite::drawzcboss(BITMAP* dest)
19581964
}
19591965
}
19601966

1961-
#ifndef IS_ZQUEST
19621967
if(show_hitboxes)
1963-
{
1964-
start_info_bmp();
1965-
al_draw_rectangle(x+hxofs,y+playing_field_offset+hyofs-(z+zofs)-fakez,x+hxofs+hxsz,(y+playing_field_offset+hyofs+hysz-(z+zofs)-fakez),hitboxColor(info_opacity),1);
1966-
end_info_bmp();
1967-
}
1968-
#endif
1968+
draw_hitbox();
19691969
}
19701970

19711971
void sprite::draw8(BITMAP* dest)

src/sprite.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ class sprite : public solid_object
131131
int32_t drownCombo; // Pitfall fallen combo
132132
bool isspawning;
133133
bool can_flicker;
134+
bool hide_hitbox;
134135

135136
byte spr_shadow, spr_death, spr_spawn;
136137
int16_t spr_death_anim_clk, spr_spawn_anim_clk;
@@ -184,6 +185,7 @@ class sprite : public solid_object
184185
virtual int32_t run_script(int32_t mode);
185186

186187
virtual ALLEGRO_COLOR hitboxColor(byte opacity = 255) const;
188+
virtual void draw_hitbox();
187189
};
188190

189191
enum //run_script modes

src/subscr.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3106,6 +3106,7 @@ void add_subscr_item(item *newItem)
31063106
{
31073107
//al_trace("Adding a subscreen item, ID: %d\n",newItem->id); //Logging stuff to remove, later.
31083108
newItem->subscreenItem=true;
3109+
newItem->hide_hitbox=true;
31093110
Sitems.add(newItem);
31103111
}
31113112

@@ -4125,6 +4126,7 @@ void buttonitem(BITMAP *dest, int32_t button, int32_t x, int32_t y)
41254126
{
41264127
Aitem->x=x;
41274128
Aitem->y=y;
4129+
Aitem->hide_hitbox = true;
41284130

41294131
switch(itemsbuf[Aitem->id].family)
41304132
{
@@ -4152,6 +4154,7 @@ void buttonitem(BITMAP *dest, int32_t button, int32_t x, int32_t y)
41524154
{
41534155
Bitem->x=x;
41544156
Bitem->y=y;
4157+
Bitem->hide_hitbox = true;
41554158

41564159
switch(itemsbuf[Bitem->id].family)
41574160
{
@@ -4181,6 +4184,7 @@ void buttonitem(BITMAP *dest, int32_t button, int32_t x, int32_t y)
41814184
//zprint2("Drawing X Item\n");
41824185
Xitem->x=x;
41834186
Xitem->y=y;
4187+
Xitem->hide_hitbox = true;
41844188

41854189
switch(itemsbuf[Xitem->id].family)
41864190
{
@@ -4211,6 +4215,7 @@ void buttonitem(BITMAP *dest, int32_t button, int32_t x, int32_t y)
42114215
//zprint2("Drawing Y Item\n");
42124216
Yitem->x=x;
42134217
Yitem->y=y;
4218+
Yitem->hide_hitbox = true;
42144219

42154220
switch(itemsbuf[Yitem->id].family)
42164221
{

src/zc/guys.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23720,7 +23720,8 @@ void check_collisions()
2372023720
{
2372123721
enemy *e = (enemy*)guys.spr(j);
2372223722

23723-
if(e->hit(w)) //boomerangs and such that last for more than a frame can write hitby[] for more than one frame,
23723+
bool didhit = w->hit(e);
23724+
if(didhit) //boomerangs and such that last for more than a frame can write hitby[] for more than one frame,
2372423725
//because this only checks `if(dying || clk<0 || hclk>0 || superman)`
2372523726
{
2372623727
// !(e->stunclk)

0 commit comments

Comments
 (0)