Hi everyone,

I am currently working on a small program that helps users create Quests for use with our open source MMO and Virtual World Platform.

I want to be able to put entries from the form attached to this post (questcreator_screen.jpg), into something similar to the below Python code:

collectQuest = MarsCollectionQuest()
collectQuest.setName("Get some skins")
collectQuest.setDesc("Kill a wolf and bring me the skin and bones")
collectQuest.setObjective("Collect 1 Wolf Skin and 1 Wolf Bones")
collectQuest.addQuestPrereq("Welcome Ashore")
collectQuest.addCollectionGoal(MarsCollectionQuest.CollectionGoal("Wolf Skin", 1))
collectQuest.addCollectionGoal(MarsCollectionQuest.CollectionGoal("Wolf Bones", 1))
collectQuest.addReward("Leather Boots")

'collectQuest' is the Unique Name
'MarsCollectionQuest()' is the type of quest, will be this if the Collection radio is selected, and 'MarsKillQuest' if the Kill radio button is selected.
'welcomeQuest.setName()' is set by Quest Name
'collectQuest.setDesc()' is set by Description
'collectQuest.setObjective()' is set by Objective
'collectQuest.addQuestPrereq()' is set by Required Quest?
'collectQuest.addCollectionGoal(MarsCollectionQuest.CollectionGoal(Item,Number))' is set by one of the Item fields in the Collect Quest section on the right, and the Number/quantity of items is set by the integer control next to it.
'collectQuest.addReward()' is set by Reward

Sorry if I was stating the obvious at times then!


So, each field is related to a piece of the Quest template.
I've worked out how to print text to a file, but I don't know how I'd go about linking each field to each python declaration. So, if I wrote 'findJonDoe' in the Unique Name field, it would put 'findJonDoe' where 'collectQuest' is in the Python file, then selecting the Kill radio button would put 'MarsKillQuest()' after, creating the first line as 'findJonDoe = MarsKillQuest()', and so on and so forth.

I'm not really sure where to start - can someone help me out?

Thanks!

Tristan

Recommended Answers

All 3 Replies

So you want to literally replace strings in your python script? Or did I just read that wrong.

A side note, it seems like your quest data is more suited to an XML file than plain text:

<quests>
  <quest name="MyQuest" objective="Some objective" required="false" ID="(Some GUID)">
     <goals>
       <collection_goal item="Wolf bones" amount="1" />
       <collection_goal item="Wolf skin" amount="1" />
       <kill_goal enemy="Evil wolf boss" amount="1" />
     </goals>
     <rewards>
       <money_reward amount="10000" />
       <item_reward item="Leather Boots" />
     </rewards>
     <locations>
       <turn_in_location name="Some guys house" npc_id="someID representing an npc"/>
       <origin_location name="Where you get the quest" npc_id="someID representing an npc"/>
     </locations>
     <prerequisites>
       <level_prereq level="10" />
       <quest_prereq quest_ID="GUID representing a different quest" />
     </prerequisites>
  </quest>
  (...append more quests here)
</quests>

I could go on all day with that, but I'm sure you get the point. Alot of APIs/SDKs exist for reading and writing to XML files, and makes for a much more organized method of saving all kinds of data. You can have your C# program add/remove/edit nodes in the xml file, then access the same xml file within python to get the attributes you are looking for :)

A lot of games are using XML files like this for almost ALL the data they contain. Check out Civilization 5, for example. You can basically rewrite the whole game (less the engine) from within its 5 XML files.

So you want to literally replace strings in your python script? Or did I just read that wrong.

The way I put it gave the wrong impression - I want it to create a new Quest, from scratch. All quests go into one file, along with mobs (NPCs) and a few other things (not sure why, but that's how the original code was written).

Regarding the XML idea - it makes sense, but the server side of the platform is all written in Python, and I can imagine it would require a fair amount of rewriting, which we don't have the manpower or time to spare at the moment. We're all volunteers, and are focussing on sorting out some of the bigger issues, like bugs :/

Now that I've clarified, is it do-able?

I don't see why not. How are you currently saving the npc/other data in this file? Could you not save the form data in a similar way?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.