summaryrefslogtreecommitdiff
path: root/tools/questdbconverter.pl
diff options
context:
space:
mode:
authordastgir <dastgirpojee@rocketmail.com>2015-01-19 08:57:53 -0500
committerHaru <haru@dotalux.com>2015-01-24 00:46:07 +0100
commit0f413f9ee34ed18fc34e1783b8ef2b9aa8813e8c (patch)
tree0043e04d632983db98e0fcd20095acfe7574cb87 /tools/questdbconverter.pl
parentd2b8de52e56914d8135c5209fb3e2a7339065b94 (diff)
downloadhercules-0f413f9ee34ed18fc34e1783b8ef2b9aa8813e8c.tar.gz
hercules-0f413f9ee34ed18fc34e1783b8ef2b9aa8813e8c.tar.bz2
hercules-0f413f9ee34ed18fc34e1783b8ef2b9aa8813e8c.tar.xz
hercules-0f413f9ee34ed18fc34e1783b8ef2b9aa8813e8c.zip
Added quest_db.txt to quest_db.conf Conversion Tool
Diffstat (limited to 'tools/questdbconverter.pl')
-rwxr-xr-xtools/questdbconverter.pl86
1 files changed, 86 insertions, 0 deletions
diff --git a/tools/questdbconverter.pl b/tools/questdbconverter.pl
new file mode 100755
index 000000000..9c59d434d
--- /dev/null
+++ b/tools/questdbconverter.pl
@@ -0,0 +1,86 @@
+#!/usr/bin/perl
+#
+# Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+# See the LICENSE file
+# Base Author: Dastgir @ http://hercules.ws
+#
+# This Script converts quest_db.txt to quest_db.conf format.
+# usage example: perl tools/questdbconverter.pl < db/quest_db.txt > db/quest_db.conf
+#
+use strict;
+use warnings;
+
+sub parse_questdb (@) {
+ my @input = @_;
+ foreach (@input) {
+ chomp $_;
+# Quest ID,Time Limit,Target1,Val1,Target2,Val2,Target3,Val3,Quest Title
+ if( $_ =~ qr/^
+ (?<prefix>(?:\/\/[^0-9]*)?)
+ (?<QuestID>[0-9]+)[^,]*,[\s\t]*
+ (?<TimeLimit>[0-9]+)[^,]*,[\s\t]*
+ (?<Target1>[0-9]+)[^,]*,[\s\t]*
+ (?<Val1>[0-9]+)[^,]*,[\s\t]*
+ (?<Target2>[0-9]+)[^,]*,[\s\t]*
+ (?<Val2>[0-9]+)[^,]*,[\s\t]*
+ (?<Target3>[0-9]+)[^,]*,[\s\t]*
+ (?<Val3>[0-9]+)[^,]*,[\s\t]*
+ "(?<QuestTitle>[^"]*)"
+ /x ) {
+ my %cols = map { $_ => $+{$_} } keys %+;
+ print "/*\n" if $cols{prefix};
+ print "$cols{prefix}\n" if $cols{prefix} and $cols{prefix} !~ m|^//[\s\t]*$|;
+ print "{\n";
+ print "\tId: $cols{QuestID}\n";
+ print "\tName: \"$cols{QuestTitle}\"\n";
+ print "\tTimeLimit: $cols{TimeLimit}\n" if $cols{TimeLimit};
+ print "\tTargets: (\n" if $cols{Target1} || $cols{Target2} || $cols{Target3};
+ print "\t{\n" if $cols{Target1};
+ print "\t\tMobId: $cols{Target1}\n" if $cols{Target1};
+ print "\t\tCount: $cols{Val1}\n" if $cols{Target1};
+ print "\t},\n" if $cols{Target1};
+ print "\t{\n" if $cols{Target2};
+ print "\t\tMobId: $cols{Target2}\n" if $cols{Target2};
+ print "\t\tCount: $cols{Val2}\n" if $cols{Target2};
+ print "\t},\n" if $cols{Target2};
+ print "\t{\n" if $cols{Target3};
+ print "\t\tMobId: $cols{Target3}\n" if $cols{Target3};
+ print "\t\tCount: $cols{Val3}\n" if $cols{Target3};
+ print "\t},\n" if $cols{Target3};
+ print "\t)\n" if $cols{Target1} || $cols{Target2} || $cols{Target3};
+ print "},\n";
+ print "*/\n" if $cols{prefix};
+ } elsif( $_ =~ /^\/\/(.*)$/ ) {
+ my $s = $1;
+ print "// $s\n" unless $s =~ /^[\s\t]*$/;
+ } elsif( $_ !~ /^\s*$/ ) {
+ print "// Error parsing: $_\n";
+ }
+
+ }
+}
+print <<"EOF";
+quest_db: (
+// Quest Database
+/******************************************************************************
+ ************* Entry structure ************************************************
+ ******************************************************************************
+{
+ Id: Quest ID [int]
+ Name: Quest Name [string]
+ TimeLimit: Time Limit (seconds) [int, optional]
+ Targets: ( [array, optional]
+ {
+ MobId: Mob ID [int]
+ Count: [int]
+ },
+ ... (can repeated up to MAX_QUEST_OBJECTIVES times)
+ )
+},
+******************************************************************************/
+
+EOF
+
+parse_questdb(<>);
+
+print ")\n";