Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Tasks] Schema simplification #2449

Merged
merged 13 commits into from
Sep 28, 2022
Merged

Conversation

hgtw
Copy link
Contributor

@hgtw hgtw commented Sep 25, 2022

This will make tooling, schema, code easier to reason about.

While denormalizing goallists may not be ideal, it decouples tasks from rewards which share the table and removes a redundant column in favor of a using the delimited string which better matches live packet data.

Akkadius

@hgtw and I have collaborated on this PR taking up different parts

Reason for Change(s)

Task system has been archaic as we've been implementing new systems (Shared Tasks) over time. This PR aims to work towards making more finalized schema simplification changes that should make things easier to reason about.

We have multiple fields doing the same thing and goal lists are also doing the same thing. Let's create one way to do things to keep things simple

Combining Fields

As @hgtw mentioned

  • Fields npc_id and npc_goal_id combine into npc_match_list which can contain a single NPC or a list of NPC's that are pipe delimited | Example (4007|4009|4013|4024|4036|4043|4078|4080) and can also contain NPC names as partials (orc|gnoll|bear)
  • Fields item_id and item_goal_id combine into item_id_list which can contain a single item or list of items that are pipe delimited | Example (37025|37029|37032)

Goallists Deprecation

This is another move in the vein of simplification. I've never seen content developers really enjoy or understand using goal lists effectively which has warranted another way to manage this sort of functionality.

The goallists table along with GoalListManger are completely deprecated and removed. The SQL takes care of automatically updating things to the new format and backs up the old tables.

Because we can flexibly manage lists inline at either the task level for reward_id_list or task_activities level for npc_match_list and item_id_list. We no longer need a goalmethod or rewardmethod type that references a list which was the goal list table.

The inline lists are far more flexible and can flexibly match on ID's or names depending on the field

For example npc_match_list will match exact ID's or name partials (orc|bear|gnoll|34024)

For example item_id_list will only do exact matches on item ID's (1001|1002|1003) etc.

These lists can be as long as they need to be and are limited by text (65,535)

Schema Consistency

Fields were changed to be consistent with snake casing to be in line with https://docs.eqemu.io/server/database/conventions-guidelines. While we shouldn't just change database fields unless we have a strong reason to, we've already been heavily iterating on this part of the code base recently so we might as well just make things how they should be and simplify what we can considering how core this system is to Dragons of Norrath content and beyond.

tasks

  • reward is now reward_text (varchar)
  • rewardid (int) is now reward_id_list (text)
  • cashreward is now cash_reward
  • rewardmethod is now reward_method
  • minlevel is now min_level
  • maxlevel is now max_level
  • xpreward is now exp_reward

task_activities

  • Fields npc_id and npc_goal_id combine into npc_match_list which can contain a single NPC or a list of NPC's that are pipe delimited | Example (4007|4009|4013|4024|4036|4043|4078|4080) and can also contain NPC names as partials (orc|gnoll|bear)
  • Fields item_id and item_goal_id combine into item_id_list which can contain a single item or list of items that are pipe delimited | Example (37025|37029|37032)

reward_id_list now contains delimited values of goallists if there was any entries that were linked. In PEQ there were 3 (2 technically)

image

Future Reward Window

When we implement the reward window it will just be its own table, because it has a structure of many other things to select from in terms of options (items, factions, etc.)

Field Usage Matrix

To be updated in official documentation

activity_type activity_type_description item_id_list npc_match_list dz_switch_id min_x max_x min_y max_y min_z max_z skill_list spell_list item_list target_name Description Format
1 Deliver x x - o o o o o o - - Name of Item(s) Name of NPC Deliver (goalcount) (item_list) to (target_name)
2 Kill - x - o o o o o o - - - Name of NPC Kill (goalcount) (target_name)
3 Loot x o - o o o o o o - - Name of Item(s) Name of NPC Loot (goalcount) (item_list) from (target_name)
4 Speak With - x - o o o o o o - - - Name of NPC Speak with (target_name)
5 Explore - - - x x x x x x - - - Name of Explore Area Explore (target_name)
6 Tradeskill x - - o o o o o o - - Name of Item(s) - Create (goalcount) (item_list) using tradeskills
7 Fish x - - o o o o o o - - Name of Item(s) - Fish for (goalcount) (item_list)
8 Forage x - - o o o o o o - - Name of Item(s)
Forage x (item_list)
- Forage (goalcount) (item_list)
9 Use (Cast On) - - - o o o o o o - Spell name(s) - Name (Anything) Use (spell_list) on (target_name)
10 Use2 (Skill On) - - - o o o o o o Skill name(s) - - Name (Anything) Use (skill_list) on (target_name)
11 Touch - - x
(doors table dz_switch_id)
o o o o o o - - - Name of Touch Target
(Touch target)
Touch (target_name)
100 Give - x - o o o o o o - - - Name of NPC Give (goal_count) to (target_name)
255 Quest Script - - - o o o o o o - - - - -

@Akkadius Akkadius changed the title Combine task_activity item and npc fields [Tasks] Schema simplification Sep 25, 2022
@Akkadius
Copy link
Member

This is not in a rush to merge. Could use some additional testing. But confidence is high on the changes.

@hgtw and myself should at least sign off on this PR when we're ready for it to merge

@Akkadius
Copy link
Member

Rewards tested working just fine

image

@Akkadius
Copy link
Member

Example Task 1

Has several activity types using lists, works beautifully

select taskid, activityid, step, activitytype, item_id_list, npc_match_list from task_activities where taskid = 1;
+--------+------------+------+--------------+--------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| taskid | activityid | step | activitytype | item_id_list | npc_match_list                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
+--------+------------+------+--------------+--------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|      1 |          0 |    1 |            1 | 36078        | 54124                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
|      1 |          1 |    2 |            5 | NULL         | NULL                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
|      1 |          2 |    3 |            4 | NULL         | 54124                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
|      1 |          3 |    4 |            2 | NULL         | 54035|54036|54207|54235|54250|54254                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
|      1 |          4 |    5 |            4 | NULL         | 54124                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
|      1 |          5 |    6 |            5 | NULL         | NULL                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
|      1 |          6 |    6 |            2 | NULL         | 5001|5002|5003|5078|5079|5080|5082|5083|5084|5085|5089|5108|5109|5112|5114|5130|9129|10000|10159|10166|20028|20033|20036|20048|20171|21005|21012|21026|21038|21039|21096|21097|21102|21107|21115|21118|21119|21121|22005|22022|22031|22052|22053|22055|22142|22143|22149|22155|22165|22171|22172|22179|30033|30034|30042|33033|33034|33036|33037|33038|33064|33108|33113|33123|33124|33156|34015|34105|35007|35008|35009|35011|35034|35039|35042|35043|35044|35052|35091|35092|35116|35129|37014|37015|37017|37018|37026|37032|37035|37040|37069|50027|50028|50033|50034|50065|50070|50211|50259|51088|51089|51090|51110|51111|54001|54003|54004|54008|54015|54016|54019|54027|54037|54039|54185|54187|54188|54190|54193|54194|54195|54200|57001|57003|57004|57015|57020|57040|57041|57056|57085|57090|57136|58000|58001|58002|58003|58004|58005|58006|58008|58009|58011|58012|58013|58015|58016|58024|58025|58026|58027|58029|58033|58034|58035|58036|58037|58038|58039|58040|58041|58042|58043|58045|58047|58053|58054|58055|68055|68056|68168|68169|68190|68200|68223|70010|70011|70042|255702|269011|269012 |
|      1 |          7 |    7 |            4 | NULL         | 54124                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
|      1 |          8 |    8 |            4 | NULL         | 202291                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
+--------+------------+------+--------------+--------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
9 rows in set (0.01 sec)

image

image

@Akkadius
Copy link
Member

Probably could use some testing by a few others, with some other tasks mixed in

@Akkadius
Copy link
Member

Added reward stacking

Below is a GIF of reward_id_list 8003|13005 (Iron ration and long bow)

Long bow is getting added every task completion, iron ration is properly stacking

Screencast from 09-26-2022 12_17_41 AM

@Akkadius
Copy link
Member

Akkadius commented Sep 27, 2022

Added optional stack counts in the reward list

reward_id_list with 8003|13005,10

13005 being Iron Ration and 10 charges

Task.Reward.Stack.Counts.mp4

@Akkadius Akkadius merged commit e883703 into EQEmu:master Sep 28, 2022
joligario added a commit to ProjectEQ/peqphpeditor that referenced this pull request Oct 18, 2022
catapultam-habeo pushed a commit to catapultam-habeo/pyrelight-server that referenced this pull request Mar 27, 2023
* Combine task_activity item and npc fields

This will make tooling easier.

While denormalizing goallists may not be ideal, it decouples tasks from
rewards which share the table and removes a redundant column in favor
of a using the delimited string which better matches live packet data.

* [Tasks] Deprecate goallists table, migrate reward goal lists, simplify logic

* Update 2022_09_25_task_concat_matchlists.sql

* Update 2022_09_25_task_concat_matchlists.sql

* Tweaks

* Fix reward column name in conversion script

* Task reward stacking

* Update task_client_state.cpp

* Implement stack counts

* Fix reward item instance memory leak

* Validate reward item instance

* Fix item reward message

* Fix findtask

Co-authored-by: Akkadius <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants