FAQ Search Memberlist Usergroups
Jolt Country Forum Index
Register Profile Log in to check your private messages Log in
Log in Log in

Ask About / Tell About and objects

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Jolt Country Forum Index -> Hugo's House of Horrors
View previous topic :: View next topic  
Author Message
Ice Cream Jonsey



Joined: 27 Apr 2002
Posts: 20088
Location: Colorado

PostPosted: Thu Jan 26, 2012 12:37 am    Post subject: Ask About / Tell About and objects Reply with quote

For the first time, I am gonna use ask about and tell about in a game. I am sure I could find this if I looked, but.... what's the industry-standard way of avoiding having to code objects for conversational topics?

So if I want to mention the weather in the game's text, and let Hugroid ask Nimroid about the weather, how do you guys set that up? I looked at Taleslinger's code for Clockwork Boy, but it seems everything you can talk about is an actual in-game object.

I'll update HxE if I get the answer!
_________________
the dark and gritty...Ice Cream Jonsey!
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Ice Cream Jonsey



Joined: 27 Apr 2002
Posts: 20088
Location: Colorado

PostPosted: Thu Jan 26, 2012 12:38 am    Post subject: Reply with quote

Whoa! And this page answers my next question, which is "keeping track of the number of times asked!"

http://hugo.gerynarsabode.org/index.php?title=DoAsk
_________________
the dark and gritty...Ice Cream Jonsey!
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Roody_Yogurt



Joined: 29 Apr 2002
Posts: 1993
Location: Milwaukee

PostPosted: Thu Jan 26, 2012 3:55 am    Post subject: Reply with quote

As far as the first question goes, I think the industry standard is making an object for the topic. I think Merk actually rewrote his conversation code to work strictly off of strings, so you could look at that if you want to go that route (EDIT: this is wrong. Merk didn't do this.). Part of the reason I gravitated to Hugo in the first place, though, was being able to use objects in my conversation code, since for whatever reason, it offended me that I had to type an object's nouns and adjectives twice.

If you do end up using the object route, the most important thing is to use the known attribute. DoAsk/DoTell use the anything grammar token, so objects being referenced do not need to be in scope but they do need to be known.

Code:

object weather "weather"
{
    article "the"
    noun "weather"
    is known
}


The nice thing about using objects- besides inheriting nouns and adjectives and such- is that you can attach whatever other properties to it. Actually, while writing this reply, it occurs to me that my 'timesasked' system would be much better off if I put the properties in every object to be asked about and not in the characters themselves, using a character-numbering system like phototalk.hug.

My 'timesasked' code is the basis that I used for my take on 'the king of shreds and patches' conversation system. I haven't polished it up for any kind of release, but you can look at it here: http://roody.gerynarsabode.org/JC/doasktopics.hug

In the next day or so, I think I will try swapping around the properties and see if it makes it that much easier to set-up (I think it might!).

Hmm, I was going to finish up this post with going over how Merk handled it with his games, but it seems like I was wrong. He has some string-y stuff in there, but for the most part, it's just the regular way.

Anyhow, you could change the DoAsk grammar to just expect a word instead of 'anything' or something, but it's going to be a big can of worms if some of your topics have two or three word names, I think. Probably not worth it.

Actually, that gives me an idea.
Back to top
View user's profile Send private message AIM Address
Roody_Yogurt



Joined: 29 Apr 2002
Posts: 1993
Location: Milwaukee

PostPosted: Thu Jan 26, 2012 4:15 am    Post subject: Reply with quote

Well, no. I was thinking you could have:
Code:

verb "ask"
* living "about" word        DoAskWord

line defined before DoAsk, but that'd both require all of your non-object topics to be one word and you'd have to recreate everything that'd normally be handled by DoAsk.

Anyhow, I will be interested in hearing where you go with this.
Back to top
View user's profile Send private message AIM Address
Roody_Yogurt



Joined: 29 Apr 2002
Posts: 1993
Location: Milwaukee

PostPosted: Thu Jan 26, 2012 4:54 am    Post subject: Reply with quote

Well, even though it's less than ideal, I threw together a DoAskWord routine to go with the above. It first checks to make sure that the word isn't an adjective or noun (originally was going to only do the latter but thought I'd let it be more receptive) before doing its thing:
Code:

object can "tin can"
{
   adjective "tin"
   noun "can"
   in STARTLOCATION
}

character fred "Fred"
{
   noun "fred"
   in startlocation
   after
      {
      object DoAsk
         {
         select xobject
            case can : "yay can!"
            case else : "I dunno!"
         }
      object DoAskWord
         {
         select xobject
            case "weather" : "Yay weather!"
            case else : return false
         }
      }
}

routine DoAskWord
{
   local i
                               ! the 29th object is either the last
   for (i=29; i <=objects;i++) ! hugolib-defined object or the first
   {                           ! non-hugolib object, depending on whether
   if ObjWord(xobject, i)      ! HugoFix is on
      return Perform(&DoAsk, object, i)
   }

   speaking = object

   if object is unfriendly
   {
      if not object.ignore_response
         Message(&Speakto, 4)    ! "X ignores you."
      speaking = 0
   }
   elseif object = player
   {
      VMessage(&DoAsk, 2)             ! "Talking to yourself..."
      return false
   }
   else
   {
      if not object.after
      {
           ! "Doesn't seem to know anything..."
            VMessage(&DoAsk, 6)
      }

#ifclear NO_SCRIPTS
      SkipScript(object)
#endif
   }
   return true
}
Back to top
View user's profile Send private message AIM Address
Flack



Joined: 18 Nov 2008
Posts: 4953
Location: Oklahoma

PostPosted: Thu Jan 26, 2012 5:31 am    Post subject: Reply with quote

I don't know if this can be applied to Hugo or not, but in "A Game of Chance" (Inform 6) I did the following with my NPCs:

life [;
Ask: switch (second) {
'slot', 'machine', 'slot machine':
"~Yeah, you did a number on that one, didn't you. I've never seen quite so much drool on a machine before.
Impressive.~";
'clock', 'time':
"~Yes sir, it's half-past time for you to go.~";
'carpet':
"~Matches the drapes, thanks.~";
'drapes':
"~Matches the carpet, duh.~";
'drink', 'drinks', 'alcohol', 'beer', 'beers', 'shot', 'shots':
"~Oh no my friend, you've had quite enough.~";
'poker', 'liquor':
"~Poker in the front, liquor in the rear. Er, wait ...~";
'weather':
"~Partly cloudy, with a chance of you being really hung over tomorrow.~";
};
Kiss: "Although the Pit Boss appreciates your offer, alas, he is on the clock.";
Attack, ThrowAt: Pit_Death();
],
before [;
Talk: Pit_Speak();
],


For objects that the player could interact with I set up actual objects, but for one-line retorts, I did them this way.
_________________
[] Jonathan "Jack" Flack []
Back to top
View user's profile Send private message Visit poster's website
Ice Cream Jonsey



Joined: 27 Apr 2002
Posts: 20088
Location: Colorado

PostPosted: Thu Jan 26, 2012 8:26 am    Post subject: Reply with quote

Just a quick reply before work and before I've had coffee: thanks for all the code samples! You guys are the best.

I figured out what was wrong. I didn't have a noun attached to the object I wanted to ask or tell about. I just had the definition like so:

npc blahblah "blahblah"
{
}

Once I threw a noun in there, it worked.

I am going to throw in the code you wrote, Roody, and see if I can get that to work though!
_________________
the dark and gritty...Ice Cream Jonsey!
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Roody_Yogurt



Joined: 29 Apr 2002
Posts: 1993
Location: Milwaukee

PostPosted: Thu Jan 26, 2012 6:29 pm    Post subject: Reply with quote

I updated my take on 'shreds and patches' to keep times-asked quantities in object properties (instead of the characters). Initially, I was hoping I could do something like this:
Code:
property timesasked #5

where it'd then give every object 5 empty elements, the way that the size property declaration gives every object a default value of 10. Unfortunately, that isn't possible so one still has to manually add the properties to every object. On the plus side, this makes the element-application a lot less wasteful (as there are going to be lots of non-topic objects), and I made adding the properties a little bit easier by making a couple object classes and then using the "inherit" function to quickly add those properties to objects (got this idea by looking at Merk's code recently).

Anyhow, I think the code is a bit more readable now. You can take a look at: http://roody.gerynarsabode.org/JC/reversetopics.hug . Anyhow, the topics-listing aspect is completely optional; you can also just make use of its time-asked-counting scheme.

Also, again going back to the original issue, if the problem is that you want to avoid responses like >GET WEATHER "You don't see that.", you could make a topic object class that has default responses like the following:
Code:
class topic_object
{
   found_in {return location}
   before
      {
      object
         {
         "Don't be silly."
         }
      xobject
         {
         if verbroutine = &DoAsk,&DoAskQuestion,&DoTell,&DoTalk
            return false
         "Don't be silly."
         }
      }
   is known
}

topic_object weather "weather"
{
   article "the"
   noun "weather"
   before
      {
               ! because it is feasible that someone might type
               ! >EXAMINE WEATHER
      object DoLook
         {
         "The weather sure is nice."
         }
      }
}
Back to top
View user's profile Send private message AIM Address
Roody_Yogurt



Joined: 29 Apr 2002
Posts: 1993
Location: Milwaukee

PostPosted: Sat Jan 28, 2012 8:15 pm    Post subject: Reply with quote

I turned this ask/tell-counting system into a library extension. You can pick it up here.
Back to top
View user's profile Send private message AIM Address
Roody_Yogurt



Joined: 29 Apr 2002
Posts: 1993
Location: Milwaukee

PostPosted: Sat Jan 19, 2013 1:55 pm    Post subject: Reply with quote

I was thinking recently about how any game with ASK/TELL should have some way of telling the player what he can ask about even if it isn't doing the fancy "times-asked"-counting I've tried to do in the posts above. I thought I'd throw together a quick example of how you can put such a thing in your game!

Code:

property ask_topics ! property to hold list of objects that can be asked about

character don "Don Rogers"
{
   in startlocation
   noun "don"
   ask_topics paul producer slash
   after
   {
      object DoAsk
      {
      select xobject
         case paul: "\"I have a better idea. I'll talk over you.\""
         case producer : "\"I have a better idea. I'll play 'The Spirit of
         Radio' again.\""
         case slash : "\"He thinks \Ihe\i knows radio!\""
         case else : "Don cuts your mic."
      }
   }
}

replace DoTalk
{
   print "You can ask "; The(object); " about ";
   NewPropertyList(object, ask_topics)
   "."
}

routine NewPropertyList(obj, prop, artic)
{
   local a, b, n, total

   for (a=1; a<=obj.#prop; a++)
   {
      if obj.prop #a ~= 0 :  total++
   }

   for (a=1; a<=obj.#prop; a++)
   {
      b = obj.prop #a
      if b
      {
         n++
         if artic
            The(b)
         else
            Art(b)

         if n <total> 2
            print ", ";
         elseif n = total - 1:  print " ";

         if n = total - 1
            print AND_WORD; " ";

      }
   }
}
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Jolt Country Forum Index -> Hugo's House of Horrors All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001 phpBB Group

Theme by Kage Musha - RPG Garden

Copyrights and trademarks are all of the belonging company. No copyright Infringement intended