Difference between revisions of "HowTo:Edit Missions:Writing addon adventures"

From VsWiki
Jump to: navigation, search
m
Line 1: Line 1:
 
{{NAV_Manual |
 
{{NAV_Manual |
 
| previous=[[HowTo:Edit_Missions:Python:Bindings|Python Bindings]]
 
| previous=[[HowTo:Edit_Missions:Python:Bindings|Python Bindings]]
| up=[[HowTo:Edit_Missions|Edit Missions]]
+
| up=[[Development:Missions|Edit Missions]]
 
| next=[[HowTo:Edit_Missions:Samples|Sample Missions]]
 
| next=[[HowTo:Edit_Missions:Samples|Sample Missions]]
 
}}
 
}}
Line 83: Line 83:
 
{{NAV_Manual |
 
{{NAV_Manual |
 
| previous=[[HowTo:Edit_Missions:Python:Bindings|Python Bindings]]
 
| previous=[[HowTo:Edit_Missions:Python:Bindings|Python Bindings]]
| up=[[HowTo:Edit_Missions|Edit Missions]]
+
| up=[[Development:Missions|Edit Missions]]
 
| next=[[HowTo:Edit_Missions:Samples|Sample Missions]]
 
| next=[[HowTo:Edit_Missions:Samples|Sample Missions]]
 
}}
 
}}
 
[[Category:HowTos|Edit Missions:Writing addon adventures]]
 
[[Category:HowTos|Edit Missions:Writing addon adventures]]
 
[[Category:Development|Edit Missions:Writing addon adventures]]
 
[[Category:Development|Edit Missions:Writing addon adventures]]

Revision as of 11:09, 21 April 2008

arrow_left.png Python Bindings arrow_up.png Edit Missions Sample Missions arrow_right.png

Honestly you merely need a basic understanding of python in order to craft your own add on adventures. But I decided to write a framework for consistently and speedily adding adventures to the general exploration of Vega Strike.

I will define "adventure" as follows: A minature mission that gets triggered by a player who goes in its system. This mission may either be persistent or nonpersistent. A persistent mission will reload the next time the triggering player launched it until the player beats the mission.

THE "QUEST" CLASS: THE ACTUAL QUEST LOGIC GOES HERE

The quest, quest_factory and lastly the adventure modules take care of most of the dirty work. All an quest class has to do is the following:

class quest_my(quest.quest):
      def __init__ (self):
          #do anything you need here
      def Execute (self):
          #do anything you need here...return 1 if you wish to execute again, 0 if you wish to
          #terminate yourself

That's it.... though there are some useful functions you may wish to call in your superclass

self.removeQuest() #this prevents your player from EVER encountering the quest again in his life
self.makeQuestPersistent() #this causes the quest to be loaded the next time your player jumps in after rebooting vegastrike

Generally before returing 0 (terminating self) in a mission you may wish to make the quest either persistent (comes back next time he starts game) or removed. Though you could also leave the quest the way it is and the next time the player goes to the system after rebooting vegastrike he'll get the same quest again :-) But in order for your quest to be complete you must have two more components

THE "QUEST FACTORY" CLASS: A CLASS THAT RETURNS THE QUEST NEEDED

Each quest must have a factory that inherits from quest.quest_factory. and must define both an init, and a create function. Optionally there's a conditional function called precondition.... That returns a boolean whether or not the quest is ripe for creation (when a player encounters it in its native system that is)

class quest_my_factory (quest.quest_factory):
    def __init__ (self):
        quest.quest_factory.__init__ (self,"quest_my")
    def create (self):
        return quest_my()
    def precondition(self,playernum):
        return Director.getSaveData(playernum,"talked_to_sandra",0)>0

The factory must have 2 and can have all 3 of the above functions:

  • is the init function (__init__) .. you must call your superclass's init with your name.
  • is the create function... this must simply return the quest class you painstakingly created above
  • is the precondition. This is optional (by default it returns 1...always true)
    • the precondition can look in the save variables and see if you have done a task (set by some other quest perhaps) and only then return 1... :-) in that case when a player encounters it for the first time it will check the precondition before launching the quest. Note the precondition does NOT get checked once the mission has been turned into a persistent mission. This is because the mission already made the decision to make itself persistent I don't expect many missions to need to be persistent. I expect more lighthearted adventures that don't drag out if a player quits, etc.

Anyhow... a good example is the persistent quest known as the quest_drone (quest_drone.py) That quest checks to see if you're near an unknown_derelect and if so it launches the badguy drone.... it makes the drone jump and follow you wherever you go until it is destroyed...it is persistent and launches the drone every time you rerun the game. Luckily if you're close to the derelect chances are you'll find the gun that you can use to kill the drone.... which brings me right smack into my next point: location location location!

THE LOCATION AND PERSISTENCE OF A GIVEN QUEST (i.e. HOOKING IT INTO privateer.py)

adventure.py has the master list of all possible quests in Vegastrike. Right now there are two (but one is stupid and will be removed soon enough...that's the default one)

adventures = {"gemini_sector/delta_prime":quest_drone.quest_drone_factory(),
              "sol_sector/celeste":quest.quest_factory("default_quest",0)}

persistent_adventures = [[quest_drone.quest_drone_factory()]
These are the only 2 lists that will ever need to be changed in the modules that are already there.

  • adventures contains a map of location to adventure. Note that there can be only 1 adventure per location (the players need to be encouraged to actually EXPLORE)
  • The second list (persistent_adventures) lists all possible "persistent adventures" (duh; though they are only loaded from if the given adventure has gotten around to calling self.makeQuestPersistent)

Anyhow just adding more cool missions to this list will make it a lot more fun to explore around and encounter strange people, strange news, and a bunch 'o cash :-P

Note that we should eventually make the news reports line up with the quests... :-) I have some ideas how to do that. Basically you can call

VS.IOmessage ("game","news","A drone was sighted in the delta prime...blah blah blah")

and then people will see it in the game when they click on GNN likewise if you send it to

VS.IOmessage ("game","bar","A drone was sighted in the delta prime...blah blah blah")

then you can hear it when you talk to the bartender :-)


arrow_left.png Python Bindings arrow_up.png Edit Missions Sample Missions arrow_right.png