quest system support

Wrote new code? Fixed a bug? Want to discuss technical stuff? Feel free to post it here.

Moderator: Moderators

obsc
Noob
Noob
Posts: 18
Joined: 11 Sep 2009, 03:58
Noob?: Yes

quest system support

#1 Post by obsc »

well, i'm not too sure if my o-kore is up-to-date, but imo it's better to write (just in case) than to remain silent - maybe it will help even a bit...

well, to the topic.

server: iRO::Valkyrie
problem: in my case there is no working support for quest system. well, actually there is something (quest list/set command), but it acts as dummy - no way to know how much mobs were killed for the moment.
my solution: the main quest-related packet (0x02b5, varlen) support is missing.
packet format:

Code: Select all

<02b5>.w <pckt_len>.w <counter_num>.w { <counter_id>.d <mob_id>.d <value>.w }.counter_num
notes:
1) w - 2-byte int
2) d - 4-byte int
3) afaik what i call "counter" is called something like "objective" in o-kore sources
a quick-fix to allow myself know how much mobs are counted for quests (well, i'd rather write code that would make "quest list" show real info, but i'm pretty much restrained since i never tried learning perl, so i can read o-kore sources using nothing but common sense):

Code: Select all

Index: ServerType0.pm
===================================================================
--- ServerType0.pm	(revision 6896)
+++ ServerType0.pm	(working copy)
@@ -400,6 +400,7 @@
 		'02B2' => ['quest_objective_info', 'v V', [qw(len amount)]],							# var len
 		'02B3' => ['quest_objective_update', 'V C x4 V v', [qw(questID state time amount)]],	# var len
 		'02B4' => ['quest_delete', 'V', [qw(questID)]],
+		'02B5' => ['quest_counter_update', 'v v', [qw(len amount)]],	# var len
 		'02B7' => ['quest_status', 'V C', [qw(questID active)]],
 		'02B8' => ['party_show_picker', 'a4 v C3 a8 C3', [qw(sourceID nameID identified broken upgrade cards unknown1 unknown2 unknown3)]],
 		'02B9' => ['hotkeys'],
@@ -7244,6 +7245,18 @@
 	delete $questList->{$args->{questID}};
 }
 
+# 02B5
+# TODO
+# note: this packet updates objects' states
+sub quest_counter_update {
+	my ($self, $args) = @_;
+	message TF("[-tmp-] quest_counter_update : len(%s) count(%s)\n", $args->{len}, $args->{amount}), "info";
+	for (my $i = 0; $i < $args->{amount}; $i++) {
+		my ($objective, $mob_id, $count) = unpack('V V v', substr($args->{RAW_MSG}, 6+$i*10, 10));
+		message TF("[-tmp-] \t quest_counter_update : objective(%s) - mob(%s) count(%s) \n", $objective, monsterName($mob_id), $count), "info";
+	}
+}
+
 # 02B7
 # TODO questID -> questName with a new table file
 sub quest_status {
sorry, if:
1) posting to the wrong section
2) someone already posted similar info - to tell the truth i did not even bother searching forums, just quick-viewed topic titles on first page
2) it was fixed/implemented already
Technology
Super Moderators
Super Moderators
Posts: 801
Joined: 06 May 2008, 12:47
Noob?: No

Re: quest system support

#2 Post by Technology »

nice, i was working on exactly the same thing!
I'm happy to see someone that is actually interested in these packets.
So now i'm going to review your patch (based on some packets), finish up the quest system and commit later.

btw, this proves the power of common sense once again. ;)

EDIT:
cleaned up and committed to SVN, please test if the quest list works fine now.
btw, thanks for providing the missing information.

EDIT2:
still i have some sort of feeling that something might be wrong. as you can read in the comment of the code.
One ST0 to rule them all? One PE viewer to find them!
One ST_kRO to bring them all and in the darkness bind them...

Mount Doom awaits us, fellowship of OpenKore!
obsc
Noob
Noob
Posts: 18
Joined: 11 Sep 2009, 03:58
Noob?: Yes

Re: quest system support

#3 Post by obsc »

well, if anyone wants to know my opinion (like hell there is anyone, but i don't care ^^;;):
i think that quest data storage should be revised. from what i see now it seems to me that it'd be more correct to store quest data something like this way:
we have something like <quests> array, which holds no actual data (as it seems to be now), but indices of other <quest_counters> array (or "objectives", whatever...). this way the structure is not bound to anything - if i want to get some counter i just look for it in <quest_counters>. as far as my 1-hour-perl-learning-looking-only-at-code knowledge tells me, now o-kore stores counters directly in <quests>'s objects - if it really is this way, to get one distinct counter data i will have to browse through all <quests> array (worst-case). this way the code can be pretty much stable without relying on assumptions like "# TODO: i'm not sure if the order here is the same as the order in quest_objective_update for the objectives, i sure do hope so". let's just say i think it's more wise to write code with less probability of "oh shit! what was that?!" - personally i would not try to assume that people in gravity are perfectly sane coders ) athena ppl mostly are, but gravity... well, not that sure ^^;;

anyways, it's just my opinion )

upd0: [ removed - i messed up ]
upd1: [ removed - i messed up ]

upd2:
well it seems to work more-or-less now. things to be done:
- fix/implement initial counter setting. now after login the counters are "0" until i kill at least one counted mob.
- do something about "quest set" causing disconnection from map server )
- improve "quest list" to show mob name. things the way they are now are not friendly:

Code: Select all

questID (60115) - mob(Coco) count(3)
...
questID (60118) - mob(Caramel) count(2)
...
quest list
--------------------------------- Quest List ----------------------------------
  0 60115                           non-active            0
  -                                 3
  1 60118                           non-active            0
  -                                 2
-------------------------------------------------------------------------------
User avatar
kLabMouse
Administrator
Administrator
Posts: 1301
Joined: 24 Apr 2008, 12:02

Re: quest system support

#4 Post by kLabMouse »

Developers. Please List packets that re related to Quest System.
May-be I can recover their structures.
obsc
Noob
Noob
Posts: 18
Joined: 11 Sep 2009, 03:58
Noob?: Yes

Re: quest system support

#5 Post by obsc »

looked at initial quest data packet (02b2 varlen). for me it seems to be something like:

Code: Select all

<02b2>.w <packet_len>.w <quest_num>.d { <quest_id>.d <ignored>.d <time>.d <counter_num>.w { <mob_id>.d <mob_count>.w <counter_name>.80b <unknown>.d }.counter_num }.quest_num
Technology
Super Moderators
Super Moderators
Posts: 801
Joined: 06 May 2008, 12:47
Noob?: No

Re: quest system support

#6 Post by Technology »

kLabMouse wrote:Developers. Please List packets that re related to Quest System.
May-be I can recover their structures.
02B1-02B7
One ST0 to rule them all? One PE viewer to find them!
One ST_kRO to bring them all and in the darkness bind them...

Mount Doom awaits us, fellowship of OpenKore!
User avatar
kLabMouse
Administrator
Administrator
Posts: 1301
Joined: 24 Apr 2008, 12:02

Re: quest system support

#7 Post by kLabMouse »

0x02b1 PACKET_ZC_ALL_QUEST_LIST
0x02b2 PACKET_ZC_ALL_QUEST_MISSION
0x02b3 PACKET_ZC_ADD_QUEST
0x02b4 PACKET_ZC_DEL_QUEST
0x02b5 PACKET_ZC_UPDATE_MISSION_HUNT
0x02b6 PACKET_CZ_ACTIVE_QUEST
0x02b7 PACKET_ZC_ACTIVE_QUEST
Technology
Super Moderators
Super Moderators
Posts: 801
Joined: 06 May 2008, 12:47
Noob?: No

Re: quest system support

#8 Post by Technology »

lets adapt all to these names, it makes things a lot less confusing.
btw, please test it because i can't...
One ST0 to rule them all? One PE viewer to find them!
One ST_kRO to bring them all and in the darkness bind them...

Mount Doom awaits us, fellowship of OpenKore!
User avatar
kLabMouse
Administrator
Administrator
Posts: 1301
Joined: 24 Apr 2008, 12:02

Re: quest system support

#9 Post by kLabMouse »

0x02b1 PACKET_ZC_ALL_QUEST_LIST

Code: Select all

struct PACKET_ZC_ALL_QUEST_LIST {
  short PacketType;
  short PacketLength;
  int questNum;
  struct QUEST_RECORD {
    unsigned long questID;
    unsigned char show;
  } quests[questNum]; // Actually, Client determinate this value by PacketLength
}
User avatar
kLabMouse
Administrator
Administrator
Posts: 1301
Joined: 24 Apr 2008, 12:02

Re: quest system support

#10 Post by kLabMouse »

0x02b2 PACKET_ZC_ALL_QUEST_MISSION

Code: Select all

struct PACKET_ZC_ALL_QUEST_MISSION {
  short PacketType;
  short PacketLength;
  int questMissionNum;
  struct QUEST_MISSION_RECORD {
    unsigned long questID;
    unsigned char show; // Optimizing Compiler sometimes makes this 4 byte long. So be WARNED!
    time_t time;
    short mobCount; // Max 3
    struct MISSION_MOB_RECORD {
	  usnigned long mobID;
	  short mobHunt;
	  char mobName[24];
    } mission_mobs[3]; // Max only 3
  } mission_data[questMissionNum]; // Actually, Client read this data one by one, unless PacketLength end.
}