* [Factions] Remove from shared memory and simplify
- Removes factions from shared memory and moves to zone based storage of repositories and changes the NPC `faction_list` to also use repositories.
- This affects NPC Factions and Faction Associations.
* Bug fixes.
* Update client.cpp
* Update client.cpp
* Update client.cpp
* Cleanup
* Update client.cpp
* Update client.cpp
* Update client.cpp
* Final push
* Update CMakeLists.txt
* Consolidate reloading.
* [Cleanup] PR # 3999 (#4039)
* [Fixes for PR # 3999
* [Reload actual in game factions, not just the umbrella data.
* syntax
* Fix typo
* Foix bug where primary_faction not filled in when no hits
* Fix typos
* Fix splash factions for kills.
* Fix typo
* Fix more variable names to be accurate
* Fix Loads to load new ones as they come in.
* Load npc_factions without primary (tasks) and support old task faction
* Rename to make way for new LoadFactionAssocition (by faction_id)
* Fix some review comments
* Add code to load factions for splash tasks and quests.
* Fix issue with sign and RewardFaction, fix Log Message
---------
Co-authored-by: Paul Coene <noudess@gmail.com>
* [Strings] Add more number formatters
# Notes
- Adds `Strings::ToUnsignedInt` for `uint32` support.
- Adds `Strings::ToBigInt` for `int64` support.
- Adds `Strings::ToUnsignedBigInt` for `uint64` support.
- Adds `Strings::ToFloat` for `float` support.
- Replaces all `std::stoi` references with `Strings::ToInt`.
- Replaces all `atoi` references with `Strings::ToInt`.
- Replaces all `std::stoul` references with `Strings::ToUnsignedInt`.
- Replaces all `atoul` references with `Strings::ToUnsignedInt`.
- Replaces all `std::stoll` references with `Strings::ToBigInt`.
- Replaces all `atoll` references with `Strings::ToBigInt`.
- Replaces all `std::stoull` references with `Strings::ToUnsignedBigInt`.
- Replaces all `atoull` references with `Strings::ToUnsignedBigInt`.
- Replaces all `std::stof` references with `Strings::ToFloat`.
* [Strings] Add more number formatters
- Adds `Strings::ToUnsignedInt` for `uint32` support.
- Adds `Strings::ToBigInt` for `int64` support.
- Adds `Strings::ToUnsignedBigInt` for `uint64` support.
- Adds `Strings::ToFloat` for `float` support.
- Replaces all `std::stoi` references with `Strings::ToInt`.
- Replaces all `atoi` references with `Strings::ToInt`.
- Replaces all `std::stoul` references with `Strings::ToUnsignedInt`.
- Replaces all `atoul` references with `Strings::ToUnsignedInt`.
- Replaces all `std::stoll` references with `Strings::ToBigInt`.
- Replaces all `atoll` references with `Strings::ToBigInt`.
- Replaces all `std::stoull` references with `Strings::ToUnsignedBigInt`.
- Replaces all `atoull` references with `Strings::ToUnsignedBigInt`.
- Replaces all `std::stof` references with `Strings::ToFloat`.
* Rebase cleanup
* Changes/benchmarks/tests
---------
Co-authored-by: Akkadius <akkadius1@gmail.com>
* Plumbing
* Batch processing in world
* Cleanup
* Cleanup
* Update player_event_logs.cpp
* Add player zoning event
* Use generics
* Comments
* Add events
* Add more events
* AA_GAIN, AA_PURCHASE, FORAGE_SUCCESS, FORAGE_FAILURE
* FISH_SUCCESS, FISH_FAILURE, ITEM_DESTROY
* Add charges to ITEM_DESTROY
* WENT_ONLINE, WENT_OFFLINE
* LEVEL_GAIN, LEVEL_LOSS
* LOOT_ITEM
* MERCHANT_PURCHASE
* MERCHANT_SELL
* SKILL_UP
* Add events
* Add more events
* TASK_ACCEPT, TASK_COMPLETE, and TASK_UPDATE
* GROUNDSPAWN_PICKUP
* SAY
* REZ_ACCEPTED
* COMBINE_FAILURE and COMBINE_SUCCESS
* DROPPED_ITEM
* DEATH
* SPLIT_MONEY
* TRADER_PURCHASE and TRADER_SELL
* DISCOVER_ITEM
* Convert GM_COMMAND to use new macro
* Convert ZONING event to use macro
* Revert some code changes
* Revert "Revert some code changes"
This reverts commit d53682f997e89a053a660761085913245db91e9d.
* Add cereal generation support to repositories
* TRADE
* Formatting
* Cleanup
* Relocate discord_manager to discord folder
* Discord sending plumbing
* Rename UCS's Database class to UCSDatabase to be more specific and not collide with base Database class for repository usage
* More discord sending plumbing
* More discord message formatting work
* More discord formatting work
* Discord formatting of events
* Format WENT_ONLINE, WENT_OFFLINE
* Add merchant purchase event
* Handle Discord MERCHANT_SELL formatter
* Update player_event_discord_formatter.cpp
* Tweaks
* Implement retention truncation
* Put mutex locking on batch queue, put processor on its own thread
* Process on initial bootup
* Implement optional QS processing, implement keepalive from world to QS
* Reload player event settings when logs are reloaded in game
* Set settings defaults
* Update player_event_logs.cpp
* Update player_event_logs.cpp
* Set retention days on boot
* Update player_event_logs.cpp
* Player Handin Event Testing.
Testing player handin stuff.
* Cleanup.
* Finish NPC Handin.
* set a reference to the client inside of the trade object as well for plugins to process
* Fix for windows _inline
* Bump to cpp20 default, ignore excessive warnings on windows
* Bump FMT to 6.1.2 for cpp20 compat and swap fmt::join for Strings::Join
* Windows compile fixes
* Update CMakeLists.txt
* Update CMakeLists.txt
* Update CMakeLists.txt
* Create 2022_12_19_player_events_tables.sql
* [Formatters] Work on Discord Formatters
* Handin money.
* Format header
* [Formatters] Work on Discord Formatters
* Format
* Format
* [Formatters] More Formatter work, need to test further.
* [Formatters] More Work on Formatters.
* Add missing #endif
* [Formatters] Work on Formatters, fix Bot formatting in ^create help
* NPC Handin Discord Formatter
* Update player_event_logs.cpp
* Discover Item Discord Formatter
* Dropped Item Discord Formatter
* Split Money Discord Formatter
* Trader Discord Formatters
* Cleanup.
* Trade Event Discord Formatter Groundwork
* SAY don't record GM commands
* GM_Command don't record #help
* Update player_event_logs.cpp
* Fill in more event data
* Post rebase fixes
* Post rebase fix
* Discord formatting adjustments
* Add event deprecation or unimplemented tag support
* Trade events
* Add return money and sanity checks.
* Update schema
* Update ucs.cpp
* Update client.cpp
* Update 2022_12_19_player_events_tables.sql
* Implement archive single line
* Replace hackers table and functions with PossibleHack player event
* Replace very old eventlog table since the same events are covered by player event logs
* Update bot_command.cpp
* Record NPC kill events ALL / Named / Raid
* Add BatchEventProcessIntervalSeconds rule
* Naming
* Update CMakeLists.txt
* Update database_schema.h
* Remove logging function and methods
* DB version
* Cleanup SendPlayerHandinEvent
---------
Co-authored-by: Kinglykrab <kinglykrab@gmail.com>
Co-authored-by: Aeadoin <109764533+Aeadoin@users.noreply.github.com>
This restores sending items to EVENT_TRADE that are updated by source
controlled delivery tasks which was removed in 7cf96ca2d8.
That patch filtered out items consumed by task updates to fix a few bugs
with items being returned despite incrementing a task:
- If an npc without a quest trade event handler was the target of a
delivery task for a NoDrop/non-Quest item, the npc would auto return
it due to the `ReturnNonQuestNoDropItems` rule.
- If an npc without a quest trade event handler was the target of a
delivery task for a non-NoDrop item, the item would be added to the
npc's loot.
- If an npc with an EVENT_ITEM/EVENT_TRADE quest handler used the Lua
or Perl trade plugins, the plugins would return task items unless
specific checks for the turned in slots existed.
The quest plugin item returns are problematic for this since they just
summon to return items not handled by the script
e.g. For a task to deliver N Large Fruit Bat Wings (item id 19616),
if a player turned in 1 Wing in slot 1 and a stack of 20 Wings in slot
2, the task would be incremented 21 times and the following Lua trade
handler would return the stack of 20 from the 2nd trade slot:
```lua
function event_trade(e)
local item_lib = require("items")
if item_lib.check_turn_in(e.trade, { item1 = 19616 }) then
eq.debug("Lua consumed 1 slot and will return other slots")
end
item_lib.return_items(e.self, e.other, e.trade)
end
```
This also occured with the perl plugin though slightly differently
since that plugin returns all slots unless the exact handin slot count
matches (requiring check_handin conditions for all slots):
```perl
sub EVENT_ITEM {
if (plugin::check_handin(\%itemcount, 19616 => 1)) {
# No issue if only one slot used for trade (item not returned)
}
# Perl fails handin check if multiple slots not checked and returns all
plugin::return_items(\%itemcount);
}
```
While that patch solved the issue, it's inconvenient and wrong to not
receive items in trade events used in a source task update. It breaks
existing trade scripts for tasks that aren't quest controlled and it
forces tasks to be changed to quest controlled and manually updated to
script any extra behavior.
This patch stores the task update count on the item instance before
dispatching it to quests. The burden is now on quests and plugins to
use that value in order to prevent returning items consumed by tasks.
`ItemInstance::RemoveTaskDeliveredItems` has been added to simplify
handling this in plugins which is also used for non-quest item returns.
This required some minor shared task refactoring
- Shared task expiration handling was moved to world. Previously this
was handled by zone and had clients self remove when a shared task
expired. This resulted in wrong messages when a task ended.
- FailTask is now implemented for shared tasks which previously only
made the client quit the shared task. It now fails the task for all
members by ending the shared task.
The `Client::EndSharedTask` api will end the client's current shared
task (removing all members). This is similiar to the `FailTask` api
except it doesn't require a `task_id` and the red task fail banner is
optional (live doesn't use it for shared tasks).
The global `end_dz_task` api was added for when a client context isn't
available. This will end a shared task if the current zone is a dynamic
zone for a shared task mission. Currently only shared tasks use dynamic
zones but this api can be expanded if support is added for tasks/quests.
The global `get_dz_task_id` was added to conveniently get the task id
for the current dynamic zone if it's used for a mission. Note this is
a database hit since that information is not available at zone level.
This fixes a bug that allowed looting items from a player's corpse to
increment a task if it didn't have an npc target defined. It looks
like this bug existed before the changes in 7482cfc0.
This also now passes count for task loot updates to handle item stacks.
Also fixes incorrectly casting Corpse to NPC on loot update
Returning non-zero from EVENT_TASK_COMPLETE will prevent task rewards
and completion emote. This is necessary for a DoN mission which scripts
a mission failure but still gives the lockout.
* 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 <akkadius1@gmail.com>
On live if a task update would affect multiple elements, only the first
one gets updated. This was added as part of the changes in 7482cfc0.
Setting `UpdateOneElementPerTask` to false will restore the old behavior
that increments all active elements matching the task update criteria.
* Add faction logging category
Probably should use this for more things
* Add FactionAssociation struct
This is simply just a struct that contains an array of faction ids and
multiplier. This can hold a maximum of 10 entries (Seru hit is 8, so 2
extra) this can be raised if need be.
* Add database changes and other data point changes
This is all the database changes and loading changes
Included is an optional SQL that will be used as a starting point, there
is likely errors or typos, but we will fix those as they are discovered.
* Add Client::RewardFaction function
This just takes the faction ID and the magnitude of the primary faction
hit and calculates the rest.
The minimum change will be either 1 or -1. We stop processing after we
see an ID of 0 and assume there will be no later entries.
The primary faction ID will always receive a hit even if there is no
faction association entries
* Add users of RewardFaction to NPC death, tasks, and QuestRewards
This will only use the new system if the magnitude is set, otherwise we
will just use the old system still
* Add quest system calls and lua QuestReward support
* Add #factionassociation command
This just calls RewardFaction, mostly useful for debugging
This allows removal of the task id limit (MAXTASKS)
There's some suspect places task data isn't verified but left unchanged
If memory use becomes too high once more live data is added tasks can be
stored in shared memory instead
The task goal system made implementing tasks a little confusing since
the goal could be ambiguous depending on type. This also didn't support
filtering on multiple goals (e.g. looting items from matching npc names
inside an area). Deliver types could specify an npc id in `delivertonpc`
but the database may have multiple npcs with the same name or a task
might want to match partial npc names.
This replaces goalids with explicit fields for npcs, items, proximity
areas, and touch switch ids. These changes make managing task data
easier without needing to update multiple tables and allows filtering
task updates by multiple criteria. To mitigate any performance impact
from merging task proximities, only clients with explore tasks in the
current zone are checked during client movement updates.
Items and npcs still support goallists but it would be possible to
denormalize entries into delimited strings to combine with the match
lists. This would also decouple task goals from reward lists.
The client task update functions were refactored to run through a single
filtering function which significantly reduces duplicated code from the
legacy task system. This will also make it easier to later implement
any unhandled types.
Since the new fields will handle filtering single entries and lists
based on having values set, `goalmethod` now only distinguishes quest
controlled from source controlled.
This is a breaking api change, `taskexploredarea` has been removed
since explore ids no longer exist.
* [Code Cleanup] Zone data loading refactor
* Update client_packet.cpp
* strcpy adjustments
* Ensure safe points get reloaded properly
* Simplify GetPEQZone and getZoneShutDownDelay
* Bring in zone_store where needed
* Update client.cpp
* Signature
* Signature
* Convert helpers to using pointers
* PR comment
* Update worlddb.cpp
* Fix loading for instances
* Fix zoning with fallback as well
* Another place for instance fallback
Some live tasks make new elements available without requiring all
currently active ones to be completed first.
This adds the `req_activity_id` field to task activities which will mark
an element active if its required activity id is completed. If a valid
value is set then it's used instead of checking the current step.
The `step` field may still be set on rows with a valid `req_activity_id`
to specify its logical step and prevent later steps from becoming active
until completed. It's only ignored when deciding if the current element
is active.
The legacy task logic for unlocking activities was completely refactored
for this. A common method has been added so both zone and world can make
use of it to determine which elements are currently active. The previous
step system should remain unchanged.
The world logic for locking shared tasks when an element became active
did not account for "sequential" mode (all steps 0), unordered steps, or
gaps in step numbers. This also resolves that issue.
* [Saylinks] Convert all GM Command Saylinks to Silent Saylinks.
- This cleans up all non-silent GM Command Saylinks that we had before due to the way they worked before. All saylinks like this should be silent now.
- Add source short hand capability for say links with same link as text.
* Defaults to r anyway.
* Spacing.
This was causing #task reloadall to desync state for shared tasks.
Characters were removed from the shared task but remained in the
character_tasks table. This CancelTask is cosmetic only to reload
the client window.
This changes task touch elements to use the dz_switch_id as the goal id
instead of checking if a player zoned. It will remove the need to script
door clicks or modify task element zone field since task packet data can
just be imported.
Functionally nothing should change in this patch. This refactors a lot
of formatting and code duplication in requests and member removals.
The long SharedTaskMessage namespace and its constants were contributing
to a lot of formatting that was difficult to read. These were shortened
since they're not all shared task specific anyway (though they should
probably just be moved to string_ids.h with other eqstrs now)
Shared task requests were refactored a little to remove an unnecessary
function that filled potential members. The separate functions used for
/taskquit and /taskremove were also combined into a single function to
remove a member while preserving live message differences.
* Add shared task element locking
This adds the `lock_activity_id` field to the tasks table which will
automatically lock a shared task when that element becomes active.
A method was added to world analogous to zone's UnlockActivities to
determine when an activity is active with respect to task steps.
Also adds quest apis to manually lock or unlock a client's shared task
* Add comment
Live sends the task updated message for every solo quest and task
increment (not just goal completed).
Also changed color to what live uses now. There are some other color
changes with shared task messages but they correspond with colors
changed in client generated messages but probably not worth chasing
down and causing inconsistency.
* Add task reward points field
This replaces the separate DoN crystal reward fields with points and
point_type fields. This will make it easier to import data from
packet/client captures and possibly better support any future clients
or tasks that don't reward through the newer reward window.
* Fix manifest column check
If a member is offline (or possibly during a race while zoning?) when
the shared task is completed they will not receive the reward. On live
the character receives their reward (with an updated replay timer) if
they enter back into game while the shared task is still active. They
keep the original replay timer if the shared task is no longer active
and do not receive a reward.
This makes it so clients are issued rewards (and a task completed
event is dispatch) if the client's task state was out of sync with a
completed shared task. To prevent characters being rewarded more than
once in case of bad sync checks, a 'was_rewarded' field has been added
to the character_tasks table and updated when rewards are assigned.
This fixes a couple bugs so the character_activities table is correctly
updated with shared task states to better detect when out of sync:
- The character_activities table is now flagged to update after syncing
shared task states. This table was not being updated if a client was
offline or inaccessible for a shared task element update.
- The character_activities table is now updated when a task element is
completed. This was only being updated for activity increments and on
completing the entire task. SaveClientState is now called at the end
of ClientTaskState::IncrementDoneCount to cover all cases.
This also has a cosmetic change to show replay timers before rewards
like live, though this will not work for shared tasks until refactoring
world code
* [Money Messages] Cleanup quest::givecash(), split, and task reward messages.
- Cleans up all the money messages using ConvertMoneyToString().
- Allows quest::givecash() to have optional parameters other than copper.
* Commification.
* Corpse messages.
* String IDs and cleanup.