Sunday, November 13, 2011

Pain in the...

It is amazing the amount of trouble you have to go to to get certain simple things done in these games, sometimes.

So, I wanted one of my companions to talk to me at random. Not that "play a sound while following" that Clover did to bitch incessantly in FO3; but rather I wanted the companion to come up to me at random, and start a semi-randomly chosen conversation -- essentially mimicking the sort of prattle a real person engages in when bored.

To get some actual randomness required considerably more code than I had expected. A random number is chosen when the NPC loads into the game world. If it matches one of three predetermined numbers, the topic is chosen, and values set to stop choosing new topics, and to start a timer. When the game is running normally, the timer is checked until it matches or exceeds the aforementioned random number's value in seconds; at which point a dialogue package is added to the NPC, who comes and initiates conversation with the player with the appropriate topic.

By doing it this way, we get random comments; but not appearing constantly, and appearing soon after changing cells, but not right after (making it all but impossible to predict when it will happen). In theory, I could set it to use a multiplier of the chosen number; to have conversation set to be initiated tens (or more) of minutes after the original topic decision is made by her script. Which I may do -- the timer is limited after all only by how creative I get with the formulas for determining how long it should run.

Well, alright: there is a character limit on the float values... but it's seven digits; which is a hell of a lot of seconds.

I wonder, some days: what would have happened, had I turned my mind to something in life that actually had a real purpose...?

9 comments:

  1. "I wonder, some days: what would have happened, had I turned my mind to something in life that actually had a real purpose...?"

    Meh... if we had done that, we'd likely have been politicians and would have been miserable anyway.

    ReplyDelete
  2. Bored companions, truly does AI become more and more human ;)

    Regarding having a purpose, being shadow ruler of the world could be pretty sweet :)

    ReplyDelete
  3. so.... Tangent to the conversation here. Anyone playing Skyrim? Herc/Nos - any plans to mod for that once Bethsoft poops out an SDK ?

    I'm liking it a lot more than I liked Oblivion, but we need the mad mods :D

    ReplyDelete
  4. "I wonder, some days: what would have happened, had I turned my mind to something in life that actually had a real purpose...?"

    Meh... if we had done that, we'd likely have been politicians and would have been miserable anyway.


    Na your be ruling the known universe!!!

    ReplyDelete
  5. @DarkSong:

    I hate to trample any dreams here, but the other Bethesda games are so great because they have YEARS worth of mods to choose from. Skyrim's not a week old yet. Give it some time and be patient... it'll happen.

    ReplyDelete
  6. I could never be a politician. Rather than "my esteemed colleague" or whatever, I'd slip up and refer to my opponent as "that lying sack of shit". I'd also be the first person in the history of the country to drag his opponent across the table and attempt to murder them during a nationally televised debate...

    Also: no to Skyrim in the forseeable future; and you won't see the really cool mods for it for a good year to two years after the toolset hits, anyway -- maybe longer; if it's a new engine, most stuff won't be "port-able" and will have to be made anew. Remember: Oblivion is more than five years old at this point, and the really interesting ones for it have only started showing up in the last couple years. Some are still trickling out even now.

    As to my little coding expedition: with NCCS v0.8 bagged and done, I removed it from my game and fired my personal plugin back up to do some new testing.

    ...I could not have choreographed the new "bored code" any better if I tried. Loaded into Old World Blues with me and said special companion; I'm standing on the terrace where you start for about ten seconds, and out of nowhere my companion grabs my attention and informs me she's bored and wants to go do something else. The only way it could be any more glorious is if I had voice files.

    ReplyDelete
  7. "The only way it could be any more glorious is if I had voice files."

    I think our neko should do some voice acting for you. :D

    ReplyDelete
  8. Lol! More appropriate timing for that to start would have to have been coded in :)

    "I think our neko should do some voice acting for you. :D "
    Hmm, you may be one to something there Darksong.

    ReplyDelete
  9. "I think our neko should do some voice acting for you. :D"


    I have the voice of a truck driver...

    ReplyDelete