Implementing: Character History
Posted: Thu Apr 11, 2013 6:38 pm
Jab, since you love distractions, I have something I've been struggling with for years (literally) and while I generally grasp the concepts, I just cannot seem to implement... so I need help.
I have a table in SQL to store many different bits of data that happen during a players career - called "character_history", or events, or progress, or whatever we want to call it. Looks something like this:
Examples, when a player:
Anyway, the part I cannot comprehend is the C++ side, of course. Years ago, Scat told me it should be a Player class map, one for each thing you're tracking (Discovery Locs for instance), so it would be like in Player, map<zone_id, vector<list_of_locs_discovered> >, then the player would also have a list of their Achievements progress - map<achievement_id, vector<progress> >, and maybe a few other smaller maps for tracking other stuff.
Things that are "stats-like" could be handled like we currently do World/Player stats now (server_stats table), only move the player stuff out of there to this new system. Deaths are not mapped, just stored immediately. Like leveling up, discovering an item, being the first to create an item via tradeskills, all that just gets written to `character_history` as it's happening.
It's the tracking of Discovery Locations that I think need to be in memory so we can flip through them quickly. Achievements as well, to see if you just passed that 500th kill.
I need to nail this system down soon so we can move forward with Achievements - not because it's an important system, but because we started it, and I'd like to finish it. And, it's kinda cool.
If my initial plan is completely whack, that's okay. Tell me how you would do this, and please find some time in your busy distractions
to help me get this off my plate once and for all. It's haunting me
Thanks
Ref:
http://eq2emulator.net/phpBB3/viewtopic ... 575#p13575
http://eq2emulator.net/phpBB3/viewtopic ... 969#p21969
I have a table in SQL to store many different bits of data that happen during a players career - called "character_history", or events, or progress, or whatever we want to call it. Looks something like this:
Code: Select all
CREATE TABLE `character_history` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`char_id` int(10) unsigned NOT NULL DEFAULT '0',
`type` enum('None','Death','Discovery','XP') COLLATE latin1_general_ci NOT NULL DEFAULT 'None',
`subtype` enum('None','Adventure','Tradeskill','Quest','AA','Item','Location') COLLATE latin1_general_ci NOT NULL DEFAULT 'None',
`value` tinyint(3) unsigned NOT NULL DEFAULT '0',
`location` varchar(200) COLLATE latin1_general_ci DEFAULT '',
`event_id` int(10) unsigned NOT NULL DEFAULT '0',
`event_date` int(10) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `CharHistoryIDX` (`char_id`,`type`,`subtype`),
CONSTRAINT `FK_character_history` FOREIGN KEY (`char_id`) REFERENCES `characters` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci- - dies in combat, it is a "Death", "Adventure", value is the spawn_id, location could be the zone name, location name, etc...
- discovers a location: "Discovery", "Location", location_id, etc.
- discovers an item: "Discovery", "Item", item_id, blah blah blah.
Anyway, the part I cannot comprehend is the C++ side, of course. Years ago, Scat told me it should be a Player class map, one for each thing you're tracking (Discovery Locs for instance), so it would be like in Player, map<zone_id, vector<list_of_locs_discovered> >, then the player would also have a list of their Achievements progress - map<achievement_id, vector<progress> >, and maybe a few other smaller maps for tracking other stuff.
Things that are "stats-like" could be handled like we currently do World/Player stats now (server_stats table), only move the player stuff out of there to this new system. Deaths are not mapped, just stored immediately. Like leveling up, discovering an item, being the first to create an item via tradeskills, all that just gets written to `character_history` as it's happening.
It's the tracking of Discovery Locations that I think need to be in memory so we can flip through them quickly. Achievements as well, to see if you just passed that 500th kill.
I need to nail this system down soon so we can move forward with Achievements - not because it's an important system, but because we started it, and I'd like to finish it. And, it's kinda cool.
If my initial plan is completely whack, that's okay. Tell me how you would do this, and please find some time in your busy distractions
Thanks
Ref:
http://eq2emulator.net/phpBB3/viewtopic ... 575#p13575
http://eq2emulator.net/phpBB3/viewtopic ... 969#p21969