Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix visibility when passenger controlling or possessing another's creature #1244

Merged
merged 47 commits into from Feb 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
89197af
Added ability to pick up and drag applicable things whilst in possession
AdamPlenty Dec 17, 2021
222fa6b
Merge branch 'master' into pr/1227
Loobinex Dec 17, 2021
345cfc2
It's now possible to remove Workshop crates from storage
AdamPlenty Dec 18, 2021
07216aa
Switched to for loop
AdamPlenty Dec 18, 2021
393af75
It's now possible to arm traps in possession.
AdamPlenty Dec 18, 2021
66f6047
Update front_input.c
AdamPlenty Dec 18, 2021
2b91913
Update front_input.c
AdamPlenty Dec 18, 2021
fd07335
Modularised code
AdamPlenty Dec 19, 2021
429e938
Update thing_creature.c
AdamPlenty Dec 19, 2021
79c8bc8
Added ability to handle gold.
AdamPlenty Dec 19, 2021
87b2bc5
Fixed gold depositing sound playing when it fails
AdamPlenty Dec 19, 2021
12e0f8d
Update creature_states_spdig.c
AdamPlenty Dec 19, 2021
fdb744b
Update creature_states_spdig.c
AdamPlenty Dec 19, 2021
e3f8463
Fixed bugs
AdamPlenty Dec 19, 2021
bd5bb76
Sound now plays when Imps take gold
AdamPlenty Dec 19, 2021
59f7653
Sound now plays when picking something up in possession
AdamPlenty Dec 19, 2021
9d822fb
Added sound for dropping something
AdamPlenty Dec 19, 2021
d713d18
Update thing_creature.c
AdamPlenty Dec 19, 2021
18b4d5a
Added Right Shift
AdamPlenty Dec 19, 2021
a80eb01
Added beeps for invalid or problematic actions
AdamPlenty Dec 19, 2021
ea4bc12
Update front_input.c
AdamPlenty Dec 19, 2021
d100a38
Added unconscious creature handling support
AdamPlenty Dec 20, 2021
fe9a15e
Make sure beeps only play for your creatures
AdamPlenty Dec 21, 2021
b7da73a
Better way of doing that
AdamPlenty Dec 23, 2021
b40fe7f
Update player_instances.c
AdamPlenty Dec 23, 2021
14ebbf2
Converted to packet
AdamPlenty Dec 23, 2021
3ddb408
Put code into separate function
AdamPlenty Dec 23, 2021
4256482
Message telling you what has been picked up is now displayed.
AdamPlenty Dec 24, 2021
a0dcce0
Optimisation
AdamPlenty Dec 24, 2021
40277aa
Picking things up now creates events
AdamPlenty Dec 26, 2021
ccbe820
Changed to ALT
AdamPlenty Dec 26, 2021
b95e37c
Update front_input.c
AdamPlenty Dec 26, 2021
4f55a47
Fixed blank Workshop message displaying on picking up creatures.
AdamPlenty Dec 26, 2021
96ba3db
You can now see properly when passenger controlling, or directly cont…
AdamPlenty Dec 27, 2021
4684ead
Use original direct control check
AdamPlenty Dec 27, 2021
5ae73d9
Fixed creature disappearing before passenger control fully kicks in
AdamPlenty Dec 27, 2021
0d407ab
Improved the new direct check
AdamPlenty Dec 27, 2021
7416a7b
Merge remote-tracking branch 'upstream/master' into ControlVisibility
AdamPlenty Dec 27, 2021
e8e0c10
Creatures who can see invisible creatures can now see them while bein…
AdamPlenty Dec 27, 2021
ad30b82
Now applies to passenger controlling too
AdamPlenty Dec 27, 2021
07565e2
Fixed log error.
AdamPlenty Dec 27, 2021
ac5ef49
Properly update field on possessing a creature
AdamPlenty Dec 28, 2021
dc83e9b
Fixed transparent creatures still blocking view if it's not owned by …
AdamPlenty Dec 28, 2021
bf7e8e4
Update player_instances.c
AdamPlenty Jan 14, 2022
74e63f5
Merge remote-tracking branch 'upstream/master' into ControlVisibility
AdamPlenty Feb 6, 2022
ea97707
Update player_instances.c
AdamPlenty Feb 6, 2022
ea3186a
Update room_data.c
AdamPlenty Feb 6, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 17 additions & 2 deletions src/creature_graphics.c
Expand Up @@ -32,6 +32,7 @@
#include "vidfade.h"
#include "keeperfx.hpp"
#include "engine_render.h"
#include "player_instances.h"

#ifdef __cplusplus
extern "C" {
Expand Down Expand Up @@ -356,7 +357,7 @@ void update_creature_graphic_field_4F(struct Thing *thing)
thing->field_4F &= ~TF4F_Transpar_Flags;
thing->field_4F &= ~TF4F_Unknown40;
// Now set only those that should be
if (((thing->alloc_flags & TAlF_IsControlled) != 0) && is_my_player_number(thing->owner))
if ( (is_thing_directly_controlled_by_player(thing, my_player_number)) || (is_thing_passenger_controlled_by_player(thing, my_player_number)) )
{
thing->field_4F |= TF4F_Unknown01;
}
Expand All @@ -372,7 +373,21 @@ void update_creature_graphic_field_4F(struct Thing *thing)
thing->field_4F |= TF4F_Transpar_4;
} else
{
thing->field_4F |= TF4F_Unknown01;
thing->field_4F |= TF4F_Unknown01;
struct PlayerInfo* player = get_my_player();
struct Thing* creatng = thing_get(player->influenced_thing_idx);
if (creatng != thing)
{
if ( (is_thing_directly_controlled_by_player(creatng, player->id_number)) || (is_thing_passenger_controlled_by_player(creatng, player->id_number)) )
{
if (creature_can_see_invisible(creatng))
{
thing->field_4F &= ~TF4F_Unknown01;
thing->field_4F &= ~TF4F_Transpar_Flags;
thing->field_4F |= TF4F_Transpar_4;
}
}
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/creature_graphics.h
Expand Up @@ -123,6 +123,7 @@ short get_creature_anim(struct Thing *thing, unsigned short frame);
short get_creature_model_graphics(long crmodel, unsigned short frame);
void set_creature_model_graphics(long crmodel, unsigned short frame, unsigned long val);
void set_creature_graphic(struct Thing *thing);
void update_creature_graphic_field_4F(struct Thing *thing);

/******************************************************************************/
#ifdef __cplusplus
Expand Down
36 changes: 35 additions & 1 deletion src/player_instances.c
Expand Up @@ -1285,7 +1285,7 @@ TbBool is_thing_directly_controlled_by_player(const struct Thing *thing, PlayerN
}
else
{
if ((player->work_state != PSt_CtrlDirect) && (player->work_state != PSt_FreeCtrlDirect))
if ((player->work_state != PSt_CtrlDirect) && (player->work_state != PSt_FreeCtrlDirect) && (player->work_state != PSt_CtrlDungeon))
{
return false;
}
Expand Down Expand Up @@ -1319,4 +1319,38 @@ TbBool is_thing_directly_controlled_by_player(const struct Thing *thing, PlayerN
}
return false;
}

TbBool is_thing_passenger_controlled_by_player(const struct Thing *thing, PlayerNumber plyr_idx)
{
if (!thing_exists(thing))
return false;
struct PlayerInfo* player = get_player(plyr_idx);
if (player_invalid(player))
{
ERRORLOG("Bad player: $d", plyr_idx);
return false;
}
else
{
if ((player->work_state != PSt_CtrlPassngr) && (player->work_state != PSt_FreeCtrlPassngr))
return false;
switch (player->instance_num)
{
case PI_PsngrCtrl:
return ( (thing->index == player->influenced_thing_idx) && (player->view_type == PVT_CreaturePasngr) );
case PI_CrCtrlFade:
return (thing->index == player->controlled_thing_idx);
case PI_PsngrCtLeave:
return (thing->index == player->influenced_thing_idx);
case PI_Unset:
case PI_Whip: // Whip can be used at any time by comp. assistant
case PI_WhipEnd:
return (thing->index == player->controlled_thing_idx);
default:
ERRORLOG("Bad player %d instance %d",plyr_idx,(int)player->instance_num);
break;
}
}
return false;
}
/******************************************************************************/
1 change: 1 addition & 0 deletions src/player_instances.h
Expand Up @@ -101,6 +101,7 @@ TbBool is_thing_passenger_controlled(const struct Thing *thing);
TbBool is_thing_query_controlled(const struct Thing *thing);
TbBool is_thing_some_way_controlled(const struct Thing *thing);
TbBool is_thing_directly_controlled_by_player(const struct Thing *thing, PlayerNumber plyr_idx);
TbBool is_thing_passenger_controlled_by_player(const struct Thing *thing, PlayerNumber plyr_idx);

struct Room *player_build_room_at(MapSubtlCoord stl_x, MapSubtlCoord stl_y, PlayerNumber plyr_idx, RoomKind rkind);
TbBool player_place_trap_at(MapSubtlCoord stl_x, MapSubtlCoord stl_y, PlayerNumber plyr_idx, ThingModel tngmodel);
Expand Down