Wednesday, May 1, 2013

more character stuff

So, the character DoGet stuff mentioned two posts ago allows >GET ALL FROM <character>. I was thinking about how this will not always be optimal behavior and what to do about that.

There's probably a grammar-based solution (especially if you use Roodylib's GRAMMAR_HELPER stuff), and actually, that is probably the easiest way to deal with it.

Still, if you want to avoid grammar-tampering, another way to do it is to replace the ExcludeFromAll routine:
replace ExcludeFromAll(obj)
{
if obj is hidden
return true

! Exclude things NPCs are carrying unless the NPC is explicitly
! given as the parent
if parent(obj) is living
{
! if IsPossibleXobject(parent(obj)) or parent(obj) = player
! return false
return true
}

return false
}
Making sure it always returns true when the parent is living gets the player a "Nothing to get." message when he tries >GET ALL FROM <character>. To change this, we'll need to add a case to NewParseErrror:

replace NewParseError(errornumber,obj)
{
     select errornumber
case 9
{
if xobject is living and children(xobject)
{
"You will have to specify one object at a time."
return true
}
else
return false
}
         case else : return false
     return true
}
So yeah, that's that. To do more complicated behavior, like allowing the first item but not allowing the rest, I'd probably incorporate the use of a global or, more likely, the word array (with SaveWordSetting and CheckWordSetting), but that  scenario is unlikely enough that I won't put it together unless I need it myself or someone asks for it.

No comments:

Post a Comment