Veure: Arbitrary Mission Actions

This little baby makes me very happy:

That is a screenshot from the completion of a level 1 mission "Find Amaidoo's E-slate." The code was painful to integrate, but it makes things like the above simple to do.

Amaidoo, an instructor at the university on the starting station, has lost her e-slate and wants you to find it. You need to keep searching the university until you find it. Searching costs stamina, so every time you search, if you don't find it, you'll lose stamina. Hope you find it quickly!

The mission graph for this mission is very simple:

+--------+     +--------------------+     +-----------------------------+
| accept | --> | search-for-e-slate | --> | give-the-e-slate-to-amaidoo |
+--------+     +--------------------+     +-----------------------------+

It's that middle step which is interesting. In the JSON it looks like sort of like this:

"action" : {
   "chance" : 10,
   "failure" : {
      "message" : "You don't find the e-slate. Searching is hard work."
   },
   "label" : "Search for the e-slate",
   "method" : "search",
   "success" : {
      "message" : "You found an e-slate, pushed into an air vent. It almost looks like someone put it there on purpose.",
      "receive" : [
         "e-slate"
      ]
   }
},

And the code driving the "search" looks like this:

sub action_search {
    my ( $self, $args ) = @_;

    my ( $success, $action ) = $self->_attempt_action($args);

    return unless $success;
    foreach my $slug ( @{ $action->{receive} } ) {
        $self->add_to_inventory($slug);
    }
    return 1;
}

What this means, now that it's working, is I can use my procedural quest generator to create arbitrary quests of out of generic actions. That wasn't quite possible before. What can I do now? I could bribe characters, blackmail them, pickpocket them, and so on. I could open a strange note I found, or just deliver it to security, or burn it, or whatever. Instead of being limited to complicated behavior I've already written, a tiny method now serves to extend game play in any way that I like.

Leave a comment

About Ovid

user-pic Freelance Perl/Testing/Agile consultant and trainer. See http://www.allaroundtheworld.fr/ for our services. If you have a problem with Perl, we will solve it for you. And don't forget to buy my book! http://www.amazon.com/Beginning-Perl-Curtis-Poe/dp/1118013840/