MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / ThiefPlayerHasItem

Function ThiefPlayerHasItem

Descent3/Player.cpp:3997–4066  ·  view source on GitHub ↗

returns true if a player has the specified item to be stolen

Source from the content-addressed store, hash-verified

3995
3996// returns true if a player has the specified item to be stolen
3997bool ThiefPlayerHasItem(int player_object_handle, int item) {
3998 object *pobj = ObjGet(player_object_handle);
3999 ASSERT(pobj);
4000 ASSERT(pobj->type == OBJ_PLAYER);
4001
4002 int playernum = pobj->id;
4003
4004 static int conv_id = -2;
4005
4006 bool is_multi = false;
4007 if (Game_mode & GM_MULTI)
4008 is_multi = true;
4009
4010 if ((playernum < 0 || playernum >= MAX_PLAYERS))
4011 return false;
4012 if (is_multi && !(NetPlayers[playernum].flags & NPF_CONNECTED))
4013 return false;
4014
4015 switch (item) {
4016 case THIEFITEM_AUTOMAP:
4017 return !is_multi;
4018 break;
4019 case THIEFITEM_HEADLIGHT:
4020 if (Players[playernum].flags & PLAYER_FLAGS_HEADLIGHT_STOLEN)
4021 return false;
4022 return true;
4023 break;
4024 case THIEFITEM_ETOSCONV: {
4025 if (conv_id == -2)
4026 conv_id = FindObjectIDName("Converter");
4027
4028 if (conv_id != -1) {
4029 int inv_count = Players[playernum].inventory.GetTypeIDCount(OBJ_POWERUP, conv_id);
4030 if (inv_count > 0)
4031 return true;
4032 }
4033 return false;
4034 } break;
4035 case THIEFITEM_CLOAK: {
4036 if (pobj->effect_info) {
4037 if (!((pobj->effect_info->type_flags & EF_FADING_OUT) || (pobj->effect_info->type_flags & EF_CLOAKED))) {
4038 return false;
4039 } else {
4040 return true;
4041 }
4042 }
4043 return false;
4044 } break;
4045 case THIEFITEM_INVULN: {
4046 if (Players[playernum].flags & PLAYER_FLAGS_INVULNERABLE) {
4047 return true;
4048 }
4049 return false;
4050 } break;
4051 case THIEFITEM_QUADFIRE: {
4052 if (pobj->dynamic_wb[LASER_INDEX].flags & DWBF_QUAD)
4053 return true;
4054 else

Callers 2

HandleCommonPowerupsFunction · 0.85
osipf_PlayerValueFunction · 0.85

Calls 3

ObjGetFunction · 0.85
FindObjectIDNameFunction · 0.85
GetTypeIDCountMethod · 0.80

Tested by

no test coverage detected