CheckReach bug
Posted: Mon Jan 23, 2012 11:06 pm
CheckReach, in hugolib.h, has difficulty dealing with components. If the player's reach is limited, they'll be told that they can't reach the component even if they are holding the item which the component is part_of. This is also true if the item is in an accessible object. The changes to CheckReach below, authored by Roody, appear to fix the problem.
Code: Select all
replace CheckReach(obj)
{
local i
if not obj or obj = parent(player)
return true
#ifclear NO_VERBS
if (verbroutine ~= &DoLook, &DoLookIn) and parent(object) and
parent(object) ~= player and
parent(object) is transparent and parent(object) is not open and
parent(object) is not living
{
VMessage(&DoGet, 5) ! "X is closed."
return false
}
#endif
if not parent(player).reach or
Contains(parent(player), obj) or ! is the object in the same object as the player
Contains(parent(player), obj.part_of) ! is the object part of something in the same place
return true
#ifclear NO_VERBS
if parent(obj) is living
{
if verbroutine ~= &DoGet, &DoLook
! "Except that X has it..."
Message(&CheckReach, 1, obj)
elseif verbroutine = &DoGet and parent(obj) is unfriendly
! "Except that X doesn't want to give it to you..."
Message(&CheckReach, 2, obj)
}
#endif
for (i=1; i<=parent(player).#reach; i++)
{
if Contains(parent(player).reach #i, obj) or ! is the object inside a reach object
Contains(parent(player).reach #i, obj.part_of) or ! is the object part of an object inside the reach object
obj = parent(player).reach #i or ! is the object a reach object
obj.part_of = parent(player).reach #i ! is the object part of a reach object
{
return true
}
}
#ifset USE_ATTACHABLES
if parent(player).type = attachable
{
if InList(parent(player), attached_to, obj)
return true
}
if obj.type = attachable
{
if InList(obj, attached_to, parent(player))
return true
}
#endif
! "You can't reach it..."
Message(&CheckReach, 3, obj)
}