Fix/finish hyudoro return delivery

- Fix item detection, matches paper sprite pickups
- Stacked hyudoros deliver item once player is not holding
This commit is contained in:
James R 2022-04-30 00:25:42 -07:00
parent 39ff9ce383
commit 3e8d50a44a

View file

@ -83,6 +83,14 @@ get_hyudoro_master (mobj_t *hyu)
return center ? hyudoro_center_master(center) : NULL; return center ? hyudoro_center_master(center) : NULL;
} }
static player_t *
get_hyudoro_target_player (mobj_t *hyu)
{
mobj_t *target = hyudoro_target(hyu);
return target ? target->player : NULL;
}
static void static void
sine_bob sine_bob
( mobj_t * hyu, ( mobj_t * hyu,
@ -193,9 +201,12 @@ deliver_item (mobj_t *hyu)
P_SetTarget(&hyudoro_target(hyu), NULL); P_SetTarget(&hyudoro_target(hyu), NULL);
K_ChangePlayerItem(player, if (player)
hyudoro_itemtype(hyu), {
hyudoro_itemcount(hyu)); K_ChangePlayerItem(player,
hyudoro_itemtype(hyu),
player->itemamount + hyudoro_itemcount(hyu));
}
S_StartSound(target, sfx_itpick); S_StartSound(target, sfx_itpick);
@ -227,6 +238,33 @@ append_hyudoro
*head = hyu; *head = hyu;
} }
static void
pop_hyudoro (mobj_t **head)
{
mobj_t *hyu = *head;
INT32 lastpos;
INT32 thispos;
if (is_hyudoro(hyu))
{
lastpos = hyudoro_stackpos(hyu);
hyu = hyudoro_next(hyu);
while (is_hyudoro(hyu))
{
thispos = hyudoro_stackpos(hyu);
hyudoro_stackpos(hyu) = lastpos;
lastpos = thispos;
hyu = hyudoro_next(hyu);
}
}
*head = hyu;
}
static boolean static boolean
hyudoro_patrol_hit_player hyudoro_patrol_hit_player
( mobj_t * hyu, ( mobj_t * hyu,
@ -273,31 +311,69 @@ hyudoro_patrol_hit_player
return true; return true;
} }
static boolean
award_immediately (mobj_t *hyu)
{
player_t *player = get_hyudoro_target_player(hyu);
if (player)
{
if (player->itemamount &&
player->itemtype != hyudoro_itemtype(hyu))
{
return false;
}
// Same as picking up paper items; get stacks
// immediately
if (!P_CanPickupItem(player, 3))
return false;
}
deliver_item(hyu);
return true;
}
static boolean static boolean
hyudoro_return_hit_player hyudoro_return_hit_player
( mobj_t * hyu, ( mobj_t * hyu,
mobj_t * toucher) mobj_t * toucher)
{ {
player_t *player = toucher->player;
if (toucher != hyudoro_target(hyu)) if (toucher != hyudoro_target(hyu))
return false; return false;
// If the player already has an item, just hover beside // If the player already has an item, just hover beside
// them until they use/lose it. // them until they use/lose it.
if (player->itemamount || player->itemroulette) if (!award_immediately(hyu))
{ {
hyudoro_mode(hyu) = HYU_HOVER; hyudoro_mode(hyu) = HYU_HOVER;
append_hyudoro(&player->hoverhyudoro, hyu); append_hyudoro(&toucher->player->hoverhyudoro, hyu);
}
else
{
deliver_item(hyu);
} }
return true; return true;
} }
static boolean
hyudoro_hover_await_stack (mobj_t *hyu)
{
player_t *player = get_hyudoro_target_player(hyu);
if (!player)
return false;
// First in stack goes first
if (hyu == player->hoverhyudoro)
return false;
if (!award_immediately(hyu))
return false;
pop_hyudoro(&player->hoverhyudoro);
return true;
}
void void
Obj_HyudoroDeploy (mobj_t *master) Obj_HyudoroDeploy (mobj_t *master)
{ {
@ -370,7 +446,10 @@ Obj_HyudoroThink (mobj_t *hyu)
case HYU_HOVER: case HYU_HOVER:
if (hyudoro_target(hyu)) if (hyudoro_target(hyu))
{
project_hyudoro_hover(hyu); project_hyudoro_hover(hyu);
hyudoro_hover_await_stack(hyu);
}
break; break;
} }
} }