Skip to content

Commit 06b42ec

Browse files
committed
add player interaction haptics and fix sa
1 parent 1b43e30 commit 06b42ec

File tree

6 files changed

+28
-7
lines changed

6 files changed

+28
-7
lines changed

components/doom/prboom/p_inter.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher)
361361

362362
// bonus items
363363
case SPR_BON1:
364+
R_PlayerPickupHealth(player, 1);
364365
player->health++; // can go over 100%
365366
if (player->health > (maxhealth * 2))
366367
player->health = (maxhealth * 2);
@@ -369,6 +370,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher)
369370
break;
370371

371372
case SPR_BON2:
373+
R_PlayerPickupArmor(player, 1);
372374
player->armorpoints++; // can go over 100%
373375
if (player->armorpoints > max_armor)
374376
player->armorpoints = max_armor;
@@ -378,6 +380,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher)
378380
break;
379381

380382
case SPR_SOUL:
383+
R_PlayerPickupHealth(player, soul_health);
381384
player->health += soul_health;
382385
if (player->health > max_soul)
383386
player->health = max_soul;
@@ -389,6 +392,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher)
389392
case SPR_MEGA:
390393
if (gamemode != commercial)
391394
return;
395+
R_PlayerPickupHealth(player, mega_health);
392396
player->health = mega_health;
393397
player->mo->health = player->health;
394398
P_GiveArmor (player,blue_armor_class);

components/doom/prboom/p_map.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1727,7 +1727,7 @@ boolean PTR_NoWayTraverse(intercept_t* in)
17271727
// Looks for special lines in front of the player to activate.
17281728
//
17291729
void P_UseLines (player_t* player)
1730-
{
1730+
{
17311731
int angle;
17321732
fixed_t x1;
17331733
fixed_t y1;
@@ -1749,10 +1749,12 @@ void P_UseLines (player_t* player)
17491749
//
17501750
// This added test makes the "oof" sound work on 2s lines -- killough:
17511751

1752-
if (P_PathTraverse ( x1, y1, x2, y2, PT_ADDLINES, PTR_UseTraverse ))
1753-
if (!comp[comp_sound] && !P_PathTraverse ( x1, y1, x2, y2, PT_ADDLINES, PTR_NoWayTraverse ))
1752+
if (P_PathTraverse ( x1, y1, x2, y2, PT_ADDLINES, PTR_UseTraverse )) {
1753+
if (!comp[comp_sound] && !P_PathTraverse ( x1, y1, x2, y2, PT_ADDLINES, PTR_NoWayTraverse )) {
17541754
S_StartSound (usething, sfx_noway);
1755+
}
17551756
}
1757+
}
17561758

17571759

17581760
//

components/doom/prboom/p_switch.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -318,9 +318,11 @@ P_UseSpecialLine
318318
linefunc = EV_DoGenCrusher;
319319
}
320320

321-
if (linefunc)
321+
if (linefunc) {
322+
// [WILLIAM] - Callback to trigger haptics when using a switch
323+
R_PlayerInteract(thing->player, line->special);
322324
switch((line->special & TriggerType) >> TriggerTypeShift)
323-
{
325+
{
324326
case PushOnce:
325327
if (!side)
326328
if (linefunc(line))
@@ -340,7 +342,8 @@ P_UseSpecialLine
340342
return true;
341343
default: // if not a switch/push type, do nothing here
342344
return false;
343-
}
345+
}
346+
}
344347
}
345348

346349
// Switches that other things can activate.
@@ -372,6 +375,11 @@ P_UseSpecialLine
372375
if (!P_CheckTag(line)) //jff 2/27/98 disallow zero tag on some types
373376
return false;
374377

378+
if (thing->player) {
379+
// [WILLIAM] - Callback to trigger haptics when using a switch
380+
R_PlayerInteract(thing->player, line->special);
381+
}
382+
375383
// Dispatch to handler according to linedef type
376384
switch (line->special)
377385
{

components/doom/prboom/r_main.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ void R_PlayerPickupArmor(player_t *player, int armor);
135135
void R_PlayerPickupCard(player_t *player, card_t card);
136136
void R_PlayerPickupPowerUp(player_t *player, int powerup);
137137

138+
void R_PlayerInteract(player_t *player, int special);
139+
138140
// called when the player is hurt. damage is the amount of health lost, saved is
139141
// the amount of health saved by armor (which is the same as the amount of armor
140142
// lost)

components/doom/src/doom.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,12 @@ extern "C" {
144144
box.play_haptic_effect(haptic_effect_index);
145145
}
146146

147+
void R_PlayerInteract(player_t *player, int special) {
148+
static auto& box = BoxEmu::get();
149+
// play 4 (sharp click - 100%)
150+
box.play_haptic_effect(4);
151+
}
152+
147153
void R_PlayerPickupWeapon(player_t *player, int weapon) {
148154
static auto& box = BoxEmu::get();
149155
// play 29 (short double click strong 3 - 60%)

components/msx/src/msx.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,6 @@ unsigned int WaitKey(void)
360360
// wait no more than 100ms for the user to press any key
361361
while (!wait_for_key(GamepadState::Button::ANY, true, 100)) {
362362
// wait for key
363-
continue;
364363
}
365364

366365
return GetKey();

0 commit comments

Comments
 (0)