187 Commits

Author SHA1 Message Date
Alex King
1ed282f6ff
[Inventory] Add GetInventorySlots() Method (#4566)
* [Inventory] Add GetInventorySlots() Method

* Update client.cpp

* Push
2025-01-05 23:48:39 -06:00
Alex King
8640776a21
[Cleanup] Cleanup Body Type Code (#4366)
* [Cleanup] Cleanup Body Type-based Code

* Update bodytypes.cpp

* Final

* Update body_type.cpp

* Cleanup

* Cleanup

* Formatting

---------

Co-authored-by: Akkadius <akkadius1@gmail.com>
2024-06-02 04:25:06 -04:00
Akkadius
405d963005 [Hotfix] "GM flag" vs "GM Flag" 2024-05-04 18:44:19 -05:00
Alex King
aa0e53f5fc
[Messages] Add GM Status and Invulnerability Messages (#4266)
* [Messages] Add GM Status and Invulnerability Messages

* Update zoning.cpp

* Finalize.

* Update corpse.cpp

* Update message

---------

Co-authored-by: Akkadius <akkadius1@gmail.com>
2024-05-04 18:07:17 -05:00
JJ
a565e5f824
[Bug Fix] Fix Corpses "Disappearing" (#4275)
This fixes corpses "disappearing" by fixing the graveyard check. Prior to the corpse overhaul (#3938), moving corpses to graveyards was assumed successful and automatically removed from the process.

Note: Will open a separate issue for the graveyard timer handling.

## Type of change

Please delete options that are not relevant.

- [x] Bug fix (non-breaking change which fixes an issue)

# Testing

Attach images and describe testing done to validate functionality.

Clients tested: RoF2

# Checklist

- [x] I have tested my changes
- [x] I have performed a self-review of my code. Ensuring variables, functions and methods are named in a human-readable way, comments are added only where naming of variables, functions and methods can't give enough context.
- [x] I own the changes of my code and take responsibility for the potential issues that occur
2024-04-20 19:56:58 -05:00
Fryguy
772fed5e30
[Feature] Corpse Overhaul (#3938)
# Corpse Overhaul

Changelog:

- Player corpses now have two timers, one specific to the rezability of the corpse and the other to cover the overall rot timer of the player corpse.
- The rezability timer is based on the online presence of the player/account and is not affected by being offline.
- The rot timer is not affected by offline/online status and will count to the rot status of the corpse.
- Corpses can be rezzed multiple times, however only the first rez that yeilds returned xp will be counted. Not other rez will return any xp. This allows for a "Poor mans COTH" as was used many times in the early eras.
- All Corpse class private/protected member variables are all now prefixed with m_
- Added Corpses logging category along with many debug logs
- Removed LoadCharacterCorpseData
- Removed LoadCharacterCorpseEntity
- Added LoadCharacterCorpse(const CharacterCorpsesRepository::CharacterCorpses, const glm::vec4 &position) which simplifies areas of consumption and reduces double queries from removing LoadCharacterCorpseData and replacing LoadCharacterCorpseEntity
- All parameters that were prefixed with in_ have been dropped
- Removed two queries from CheckIsOwnerOnline and have it query the world's CLE by account_id since that is how live works
- Regenerated repository character_corpses
- Cleaned up many list iterators to use range based for loops
- Rate limit Corpse::Process m_is_rezzable with a 1 second check timer
- General code cleanup
- Added a Server Up check to bury all corpses in instances to prevent lost corpses if an instance is released during server down. This facilitates player recovery via shadowrest or priests of luclin.


This PR also now fixes a long standing issue with HasItem performance in our script plugins. It is significantly faster, we will need to coordinate quest changes and comms with operators.

```lua
    if ($client->HasItemOnCorpse($item_id)) {
        return 1;
    }
```

```lua
    --corpse
    if self:HasItemOnCorpse(itemid) then
        return true
    end
```


Testing Completed:

- Create a Corpse
- Standard rezzing
- Ghetto Coth (No Extra XP)
- Rezzing after graveyard move
- Divine Rez works as intended
- No XP Rez (Corpse Call) does not give XP
- Corpse Burying
- Cross Instance Graveyard Corpse movement/Rezzing
- DZ End/Quit Corpse Movement/Rezzing
- Server Shutdown/Reinit DZ Corpse Movement/Rezzing


---------

Co-authored-by: Akkadius <akkadius1@gmail.com>
2024-02-07 23:02:30 -05:00
Chris Miles
c654c1d674
[Loot] Remove from shared memory, simplification (#3988)
* First pass of pulling loot out of shared memory, functional

* More code cleanup

* More cleanup

* More cleanup

* More cleanup

* Add loot reload type

* Reload, logging

* Update npc.h

* Cleanup

* Logging, don't load attempt to load loottable id 0

* Update worldserver.cpp

* Update client.cpp

* Update zone_loot.cpp

* PR feedback

* Update zone.cpp

* Memory leak suggestion

* Update CMakeLists.txt

* Post rebase issues
2024-02-05 15:17:53 -06:00
Alex King
77c0eb3998
[Character] Convert Character Corpses to Repositories (#3941)
* asdsa

* Final push

* Update character_corpses_repository.h

* Update character_corpses_repository.h

* Update zonedb.cpp

* Update zonedb.cpp

* Final push

* Update character_corpses_repository.h
2024-01-13 00:02:44 -06:00
Alex King
259add68f5
[Commands] Cleanup #appearance Command (#3827)
* [Commands] Cleanup #appearance Command

# Notes
- Cleanup messages and logic.
- Cleanup appearance type constants to use a namespace with constexpr instead.
- Cleanup animation constants to use a namespace with constexpr instead.

* Update emu_constants.cpp

* Cleanup
2024-01-06 22:24:32 -06:00
Alex King
6c2886a71d
[Cleanup] Fix casing in corpse money and decay time. (#3511)
# Notes
- These were uppercase and should be lowercase.
2023-07-23 16:19:07 -04:00
Aeadoin
f752b57a55
[Cleanup] Cleanup uses of insert/push_back when a temp object is used. (#3170) 2023-04-03 16:45:01 -04:00
Aeadoin
0df84e1ee6
[Crash] Fix out of bound arrays, other potential crashes (#3166) 2023-04-01 12:44:41 -04:00
Alex
5a6314e1a9
[Fix] Fixes for corpses not properly saving some item instance data correctly. (#3123)
* Convert ZoneDb::LoadCharacterCorpseData to use a cleaner api that has a better layout.

* Update corpse save methods to use a new cleaner api.

* Add item to corpse will use a few new fields that don't yet save.

* Fix for some issues moving data to corpses.

* Make CreateItem more explicit to avoid overlooking places it's used and add more arguments.

* DB changes

* Revert of the changes to the database.CreateItem api change.

* Missed one.

* Fixes for mr Krab

* Small formatting

---------

Co-authored-by: KimLS <KimLS@peqtgc.com>
Co-authored-by: Akkadius <akkadius1@gmail.com>
2023-03-23 01:16:52 -05:00
Aeadoin
d6b954a4b9
[Cleanup] Cleaning up Raid.cpp (#3125)
* [Cleanup] Cleanup Raid.cpp

* cleanup

* fix is_bot instances

* bracket cleanup

* bracket cleanup

* rename variables in struct

* fix for merge
2023-03-20 11:39:14 -04:00
Alex King
3f1848b01a
[Cleanup] Remove can_corpse_be_rezzed from corpse.h (#3077)
# Notes
- This is unused.
2023-03-16 20:47:25 -04:00
cybernine186
be567af70d
[Bug Fix] Cursor Coin Upon Death (#3020)
* Update corpse.cpp

* Add rule toggle.

---------

Co-authored-by: Kinglykrab <kinglykrab@gmail.com>
2023-03-04 17:45:42 -05:00
Alex King
5ef8f8c3a8
[Quest API] Export $item and $corpse to EVENT_LOOT and EVENT_LOOT_ZONE in Perl (#2878)
* [Quest API] Export $item and $corpse to EVENT_LOOT and EVENT_LOOT_ZONE in Perl

# Notes
- Exports `$item` and `$corpse` to `EVENT_LOOT` in Perl.
- Exports `$item` and `$corpse` to `EVENT_LOOT_ZONE` in Perl.

* Optional parsing.

* Update corpse.cpp

* Cleanup

* Export changes

---------

Co-authored-by: Akkadius <akkadius1@gmail.com>
2023-02-12 23:45:26 -06:00
Chris Miles
d9f545a5ec
[Logging] Implement Player Event Logging system (#2833)
* 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>
2023-02-12 21:31:01 -06:00
Akkadius
54050924d8 Revert "[Quest API] Cleanup string copies and push_backs. (#2807)"
This reverts commit bcc2e022dcc41261ff2f1a7643ee6ed3e376e678.
2023-01-31 20:30:34 -06:00
Alex King
bcc2e022dc
[Quest API] Cleanup string copies and push_backs. (#2807)
# Notes
- Several places use `push_back` instead of `emplace_back`.
- Several places use `std::string` instead of `const std::string&`.
2023-01-29 15:14:49 -05:00
Natedog2012
1fe79f430c
[Feature] ResetItemCooldown added to lua/perl and fix item re-cast times to show properly (#2793)
* Testing.

* Add ResetItemCooldown and port it over to perl

* This flag needs to be set for updating shared item cooldowns

* Properly set item recast for all item types, on corpses, on looting

* SummonItem properly sets recast timers of summoned items

* Rename variable to avoid confusion and change manifest to be more specific

* Sanity check item_d

* Recast -1 added as RECAST_TYPE_UNLINKED_ITEM
ResetItemCooldown will still remove cooldown of item that we don't have so when we acquire it the cooldown is reset

* change magic numbers

* more magic numbers

* More constants yay

* Remove unneeded export DeleteItemRecastTimer

* Remove duplicate message, this is handled by the client in this part of the code

Co-authored-by: Kinglykrab <kinglykrab@gmail.com>
2023-01-25 20:09:08 -06:00
Alex King
3335cacac1
[Bots] Cleanup and remove preprocessors. (#2757)
* [Bots] Cleanup and remove preprocessors.

- Removes every `#ifdef BOTS` we have and locks bots behind `Bots:AllowBots` rule.
- Bot updates are now done by default similar to regular database updates.
- Modify `CMakeLists.txt`, `.drone.yml`, and `BUILD.md` to match the removal of `EQEMU_ENABLE_BOTS`.

* Cleanup

- Add SQL for enabling bots for servers with bots.
- Add message that tells players/operators bots are disabled.

* Suggested changes.

* Bot injection stuff

* Change SQL to bot SQL.

* Tweaks

* Remove `is_bot`

* Update version.h

* Update main.cpp

* Update database.cpp

* Fix name availability crash

* Remove bots from update script

Co-authored-by: Akkadius <akkadius1@gmail.com>
2023-01-20 12:35:33 -06:00
Alex King
a590ea1d52
[Feature] Add "Keeps Sold Items" Flag to NPCs (#2671)
# Perl
- Add `$npc->GetKeepsSoldItems()`.
- Add `$npc->SetKeepsSoldItems(keeps_sold_items)`.

# Lua
- Add `npc:GetKeepsSoldItems()`.
- Add `npc:SetKeepsSoldItems(keeps_sold_items)`.

# Notes
- Allows operators to keep specific NPCs from keeping items sold to them.
- Keeps NPCs from being cluttered with stuff like Cloth Caps, Bone Chips, etc.
2022-12-25 16:36:20 -05:00
hg
3d7c43e92f
[Quest API] Add ResetDecayTimer() to Perl/Lua. (#2520) 2022-11-06 10:48:10 -05:00
hg
070bf64d6a
[Tasks] Only update loot tasks for NPC corpses (#2513)
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
2022-11-05 11:13:02 -04:00
hg
7482cfc066
[Tasks] Replace task goals with explicit fields (#2402)
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.
2022-09-01 19:18:21 -05:00
Aeadoin
149fa54cfa
[Feature] Implement Heroic Strikethrough to NPCs (#2395)
* [Feature] Implement Heroic Strikethrough to NPCs

* Removed virtual from inline int32 GetHeroicStrikethrough()

* Fix formatting

* Removed unnecessary function
2022-08-30 23:29:41 -05:00
Michael Cook (mackal)
5331f4d841
[CPP] Update C++ standard to C++17 (#2308)
* Update C++ standard to C++17

* Nuke EQ::Any in favor of std::any

* Remove std::iterator due to deprecation

* Replace result_of with invoke_result due to deprecation
2022-07-27 09:00:09 -05:00
Chris Miles
dfd8f84cac
[Strings] Refactor Strings Usage (#2305)
* Initial commit checkpoint

* More functions converted

* Commify

* More functions

* Fin

* Sort declarations

* Split functions between files

* Bots

* Update strings.h

* Split

* Revert find replaces

* Repository template

* Money

* Misc function

* Update CMakeLists.txt

* Saylink

* Update strings.cpp

* Swap Strings::Saylink for Saylink::Create since saylink is coupled to zone database

* API casings
2022-07-14 02:10:52 -05:00
Kinglykrab
bcf7ccefcd
[Money Messages] Cleanup quest::givecash(), split, and task reward messages. (#2205)
* [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.
2022-05-29 14:33:18 -04:00
Chris Miles
5b4aeaa457
[Code Cleanup] Remove this-> in code where its implied (#2088) 2022-05-01 10:22:09 -04:00
Kinglykrab
1b7c12297d
[Quest API] Add AddPlatinum(), GetCarriedPlatinum() and TakePlatinum() to Perl/Lua. (#2079)
* [Quest API] Add AddPlatinum(), GetCarriedPlatinum() and TakePlatinum() to Perl/Lua.
- Allows for easier NPC interactions.
- GetCarriedPlatinum() adds together all currencies in inventory based on conversion amounts so it works easily with removals/checks.
- Add $client->AddPlatinum(platinum, update_client) to Perl.
- Add $client->GetCarriedPlatinum() to Perl.
- Add $client->TakePlatinum(platinum, update_client) to Perl.
- Add client:AddPlatinum(platinum, update_client) to Lua.
- Add client:GetCarriedPlatinum() to Lua.
- Add client:TakePlatinum(platinum, update_client) to Lua.

* Formatting.
2022-04-30 10:57:05 -04:00
Kinglykrab
0400504adc
[Bug Fix] NPC::CountItem and Corpse::CountItem 0 Charge Item Fix. (#1959)
- Fixes an issue where 0 charged or out of charge items do not count towards the return value.
2022-02-04 06:07:46 -05:00
Kinglykrab
5470ec6293
[Commands] Cleanup #corpse Command. (#1790)
- Cleanup message and logic.
- Add ConvertMoneyToString(platinum, gold, silver, copper) helper method.
- Cleanup NPC::QueryLoot() and Corpse::QueryLoot().
2021-11-21 14:02:03 -05:00
Kinglykrab
293361a1f7
[Cleanup] Make use of AccountStatus constants wherever status is checked or used. (#1764)
* [Cleanup] Make use of AccountStatus constants wherever status is checked or used.
- Cleanup all instances of SendEmoteMessage.
- Cleanup all instances of SendEmoteMessageRaw.
- Cleanup all instances of MessageStatus.
- Convert Quest API method defaults to use constants.

* Cleanup constant names.
2021-11-14 21:01:13 -06:00
Kinglykrab
c98f3cfb4c
[Quest API] Further char array cleanup. (#1634)
- Cleans up the rest of the char arrays used when exporting to events.
- Converts all events to use a similar variable name for export `export_string`.
- Needless calls to .c_str() removed.
2021-10-24 16:06:22 -05:00
Natedog2012
7823ff5336
[Quest API] Add EVENT_LOOT_ZONE to zone_controller (#1608)
* Add EVENT_LOOT_ZONE to zone_controller

* Fix porting event_loot_zone to lua API

* Remove extra spacing and remove forced message to allow for scripted responses.

* Allow all script parsing to fire before sending a failed lootitem, add corpse_id

* Only search for zone_controller once
2021-10-16 23:19:19 -05:00
Kinglykrab
fa8d8eccc2
[Quest API] Add corpse->RemoveItemByID(item_id, quantity) to Perl and Lua. (#1535)
* [Quest API] Add corpse->RemoveItemByID(item_id, quantity) to Perl and Lua.
- Add $corpse->RemoveItemByID(item_id, quantity) to Perl.
- Add corpse:RemoveItemByID(item_id, quantity) to Lua.

* Formatting.
2021-09-13 15:42:04 -04:00
Kinglykrab
56b9b6f2c4
[Quest API] Add corpse->GetLootList() and npc->GetLootList() to Perl and Lua. (#1529)
* [Quest API] Add corpse->GetLootList() and npc->GetLootList() to Perl and Lua.
- Add $corpse->GetLootList() to Perl.
- Add $npc->GetLootList() to Perl.
- Add corpse:GetLootList() to Lua.
- Add npc:GetLootList() to Lua.

Returns an array of item IDs for use with corpse and NPC methods such as HasItem(item_id), CountItem(item_id), and GetFirstSlotByItemID(item_id).

* Categories.

* Modify Lua to use classes.
2021-09-12 22:38:38 -05:00
Chris Miles
e7dd8d49a9
[Shared Tasks] Shared Tasks System Implementation (#1451)
* Shared tasks WIP; lots of logging; shared tasks and tasks work internally the same for now; lots to cleanup yet

* Update task_manager.cpp

* Add tables

* World message handler

* Zone message handler

* More messaging

* More rearranging

* Task creation work (wip)

* Tweaks

* Decoupled things, added a shared task manager, moved logic to the manager, created the shared task object, now creating a sense of state on creation and members, zero validation, happy path

* Cleanup unnecessary  getter

* More work on shared task persistence and state loading

* Add int64 support into repositories

* More state handling, creation loads all tables

* Wrap up shared task state creation and removal

* Move more lookup operations to preloading (memory). Restore shared task state during world bootup

* Implement shared task updates

* Add members other than just leader in task confirmations

* Update shared_task_manager.cpp

* Hook task cancellation for shared task removal (middleware)

* Remove dynamic_zone_id from SharedTasks model in repositories (for now) since we will likely be one to many with DZ objects

* Get members to show up in the window on creation

* Add opcodes, cleanup

* Add opcode handlers

* Split some methods out, self removal of shared task and updating members

* Implement offline shared task sync

* Style changes

* Send memberlist on initial login; implement remove player from shared task window

* Refactorings, cleanup

* Implement make leader in shared tasks window

* Implement add player, sync shared task state after add

* Add opcodes for remaining clients

* Shared task invite dialogue window implementation and response handling (including validation)

* Logging

* Remove comment

* Some cleanup

* Pass NPC context through shared task request logic

* Remove extra SharedTaskMember fields

* Add message constants

* Remove static

* Only use dz for expedition request

This passes expedition creation parameters through DynamicZone instead
of injecting ExpeditionRequest since it can hold creation data now

* Store expedition leader on dz

This shifts to using the leader object that exists in the core dynamic
zone object. It will be moved to the dynamic zone table later with other
columns that should just be on the dz to make loading easier.

Expeditions are probably the only dz type that will use this for window
updates and command auth. Other systems on live do fill the window but
don't keep it updated

* Store expedition name on dz

This uses the name stored on dz (for window packets) instead of
duplicating it. This will be moved completely to dz table later

* Store uuid on dynamic zone

This lets dynamic zones generate the uuid instead of expeditions. Other
dz type systems may want to make use of this. Lockouts should also be
moved to dynamic zones at some point in the future so this will be
necessary for that

* Move expedition db columns to dz

These columns should just belong to the core dynamic zone. This will
simplify loading from the database and in the future a separate
expedition table may no longer be necessary.

* Move window packet methods to dz

It makes more sense for these methods to be in the core

This will also allow support for other systems to use the window, though
live behavior that updates the window for shared task missions when not
in an expedition is likely unintended since it's not updated on changes.

* Store dynamic zone ids on clients

These will now be used for client dynamic zone lookups to remove
dependency on any dz type system caches

* Move member management to dz

This moves server messaging for adding and removing members to internal
dynamic zone methods

Set default dz member status to Unknown

* Move member status caching to dz

This moves world member status caching into internal dz methods

Zone member updates for created expeditions are now async and sent after
world replies with member statuses. Prior to this two memberlist packets
were sent to members in other zones on creation to update statuses.

This also fixes a bug with member statuses being wrong for offline raid
members in the zone that created an expedition. Note that live kicks
offline players out of raids so this is only to support emu behavior.

* Move member status updates to dz

* Set dz member status on all client dzs

This also renames the zone entry dz update method and moves window
update to a dynamic zone method. Eventually expedition components
should just be merged with dz and handled as another dz type

* Save instance safe return on characters

Add character_instance_safereturns table and repository

Previously dz safe return only worked for online characters via the dz
kicktimer or offline characters with a workaround that moved them when
an expedition was deleted. There were various edge cases that would
cause characters to be moved to bind instead (succoring after removal,
camping before kick timer, removed while offline, bulk kickplayers
removal with some offline)

This updates a character's instance safereturn every time they enter a
zone. If a character enters world in an instance that expired or are no
longer part of they'll be moved to their instance safereturn (if the
safereturn data is for the same zone-instance). Bind is still a fallback

This may also be used for non-dz instancing so it's named generically

This removes the expedition MoveMembersToSafeReturn workaround which
deprecates the is_current_member column of dynamic_zone_members and
will be removed in a followup patch.

* Remove is_current_member from dz members

This was only being used in the workaround to move past members to
dz safereturns if they were still inside the dz but not online

* Let dz check leader in world

This moves expedition leader processing in world to the dynamic zone.
This is a step in phasing out the separate expedition class for things
that can run off the dynamic zone core with simple dz type checks

This greatly simplifies checking leader on member and status changes
without needing callbacks. Other dz types that may use the dz leader
object can just handle it directly on the dz the same as expeditions

* Let dz handle member expire warnings

This moves expire warning checks to dz. This will make it easier for
other dz types to issue expire warnings if needed

* Use separate dynamic zone cache

Dynamic zones are no longer member objects of expeditions and have been
placed into their own cache. This was done so other dz types can be
cached without relying on their systems. Client and zone dz Lookups are
now independent of any system

This continues the process of phasing out a separate expedition cache.
Eventually expeditions can just be run directly as dynamic zones
internally with a few dz type checks.

Add dz serialization methods (cereal) for passing server dz creation

Modify #dz list to show cache and database separately. Also adds #dz
cache reload. This command will reload expeditions too since they
currently hold references to the dz in their own zone cache.

Add a dynamic zone processing class to world to process all types and
move expedition processing to it

* Move expedition makeleader processing to dz

* Let dz handle expedition deletions

This removes the need for separate expedition cache in world

This will greatly simplify world dynamic zone caching and processing.
Dynamic zones that are expeditions can just handle this directly. Once
lockouts and other components are completely moved to dynamic zones the
separate expedition cache in zone will also no longer be necessary

* Remove ExpeditionBase class

Since world no longer caches expeditions this will not be necessary

* Fix windows compile

* Implement task dz creation

Prototype dz creation for shared tasks

* Add and remove shared task members from dz

Also keep leader updated (used in choose zone window)

* Fix client crash on failed shared task

* Fix linux compile and warning

* Check client nullptr for dz message

This was accidently removed when expedition makeleader was moved

* Disable dz creation for solo tasks

* Add shared task repository headers to CMakeLists

* Add shared task dynamic zones table

* Add shared task dz database persistence

* Get members from db on shared task dz creation

This fixes a case where removing a member from a shared task dz would
fail if the member's name was empty. This could happen if the shared
task dz was created while a member was offline.

This also changes the dz member removal method to only check id. It
might be possible to change all dz member validations to only check
ids since names are primarily for window updates, but shared task dz
member names need to be non-empty anyway to support possible live-like
dz window usage in the future.

* Add character message methods to world

Add simple and eqstr message methods to ClientList

Add shared task manager methods to message all members or leader

* Add SyncClientSharedTaskState and nested sync strategies to cover M3 work

* Fix whitespace

* Implement task request cooldown timer

This implements the task request cooldown (15 seconds) that live uses
when a task is accepted. This will also need to be set when shared
tasks are offered (likely due to additional group/raid validations)

* Implement shared task selector validation

This implements the validation and filtering that occurs before the task
selection window is sent to a client for shared tasks

To keep things live-like, task selectors that contain a shared task will
be run through shared task validation and drop non-shared tasks. Live
doesn't mix types in task selections and this makes validation simpler.

Also note that live sends shared task selectors via a different opcode
than solo tasks but that has not been implemented yet

* Add separate shared task select opcodes

Live uses separate opcodes for solo and shared task selection windows

* Convert ActivityType to enum class

* Refactor task selector serialization

This adds serializer methods to task and task objective structs for the
task selection windows. This combines the duplicate task selector
methods to reduce code duplication and simplify serialization

* Add shared task selector

This sends shared task selection window using the shared task specific
opcode and adds an opcode handler for shared task accepts which are sent
by client in response to setting selection window to shared task type.

* Refactor task objective serialization

This adds a serialization method to the task objective struct for
serializing objectives in the window list and combines the separate
client-based methods to reduce duplicated code.

* Add task level spread and player count columns

* Implement shared task accept validation

This adds a common method for shared task character request queries

* Add task replay and request timer columns

* Add character task timers table

* Use shared task accept time on clients

This overrides client task accept time with shared task's creation time.
This is needed for accurate window task timers and lockout messages
especially for characters added to shared tasks post creation

* Implement task timer lockouts

This implements replay and request task timers for solo and shared tasks

* Add solo and shared task timer validation

* Remove logging of padding array

This gets interpreted as a c string which may not be null terminated

* Implement /kickplayers task

This also fixes current CancelTask behavior for leader which was
performing kickplayers functionality through the remove task button

* Implement /taskquit command

* Implement shared task invite validation

Remove active invitation before invite accept validation

* Remove local client db persistence during SyncClientSharedTaskRemoveLocalIfNotExists

* Add missing accept time arg to assign task

* Only validate non-zero task invite requirements

* Fix task error log crash

* Separate task cooldown timer messaging

* Use method to check for client shared task

* Avoid unneeded task invite validation query

Only need to query character data for levels for non-zero level spread

* Implement /tasktimers command

May want to add some type of throttled caching mechanism for this in
the future

* Add /tasktimers rate limiter

* Intercept shared task completion; more work to come

* Change SharedTaskActivityState and SharedTasks time objects to datetime

* Add updated_time updates to SharedTaskActivities

* Mark shared tasks as complete when all activities are completed

* Save a database query on shared task completion and use the active record in memory

* Don't record shared task completions to the quest log

* Implement RecordSharedTaskCompletion, add tables, repositories

* Update shared_task_manager.cpp

* Update shared_task_manager.cpp

* Add shared task replay timers

This is still not feature complete. On live any past members that ever
joined the shared task will receive a replay timer when it's completed

* Create FindCharactersInSharedTasks that searches through memory

* Remove namespace shorthand and formatting

* More minor cleanup

* Implement PurgeAllSharedTasks via #task command

* Add #task purgetimers

* Decrease m_keepalive time between processes

* Remove type ordering in /tasktimer query

* Add comment for task packet reward multiplier

This is likely a reward multiplier that changes text color based on
value to represent any scaled bonus or penalty

* Add replay timers to past members

This implements the live behavior that adds replay timers to any
previous member of a shared task. This likely exists to avoid possible
exploits.

Shared task member history is stored in memory and is used to assign
replay timers. This history will be lost on world crashes or restarts
but is simpler than saving past member state in database.

This also makes world send shared task replay timer messages since
past members need to be messaged now

* Move PurgeTaskTimers client method to tasks.cpp

* Remove dz members when purging shared tasks

Server dz states need to be updated before shared tasks are deleted

* Use exact name in shared task invites

This removes the wildcards from shared task invite character queries
which was sometimes selecting the wrong character

Taskadd validation is called even for invalid characters to allow for
proper messages to occur

* Clear declined active shared task invitations

This also notifies leader for declined shared task invites

* Store shared task member names

This adds back the character name field to SharedTaskMember. This should
make serialization easier in the future and reduce database lookups when
names are needed for /task commands

* Implement /taskplayerlist command

* Replace queries with member name lookups

Now that shared task members store names these queries are unnecessary

This also adds not-a-member messages for /taskremove and /taskmakeleader

* Implement shared task member change packet

This avoids sending the full member list to members when a single member
is added or removed and lets the client generate chat messages for it.

* Serialize shared task member list from world

This uses cereal to serialize the full member list from world and
removes the zone query workarounds

* Initialize client task state array

This was causing sql query errors on client state reloads

The client task information array was uninitialized resulting in being
filled with 0xcdcdcdcd values in msvc debug builds. Under release builds
this may have resulted in indeterminate values

A better fix would be to refactor some of this legacy code

* Add shared task command messages

Add messages for non-leader task commands

This adds taskadd, taskremove, taskmakeleader, and taskquit messages

The leader receives double messages for taskremove like live due to the
client generated message as well as the explicit one. It also receives
double server messages if the leader /taskremoves self.

* Replace some task messages with eqstrs

This also updates to use live colors

* Avoid shared task invite leader lookup query

Since member names are stored now this query is also unnecessary

* Avoid reloading client state on shared task accept

This was unnecessarily reloading client task state when added to a
shared task.

This also resulted in all active tasks being resent to shared task
members on creation. The shared task itself is the only task that
needs to be sent which is handled by AcceptNewTask.

* Remove active shared task invite on zone

Live doesn't re-send shared task invites after zoning like it does for
expeditions so there's no need to keep these around. This fixes active
invitations never getting reset on characters that zone or go offline.

* Choose new shared task leader if leader removed

* Add separate shared task kickplayers method

* Enable EVENT_CAST_ON for clients

This will be required for a shared task objective (The Creator) in DoN

* Revert "Avoid reloading client state on shared task accept"

This reverts commit 3af14fee2de8b109ffb6c2b2fc67731e1531a665.

Without this clients added to a task after some objectives have been
completed don't get updated state. Will need to investigate this later

* Disallow looting inside a dz by non-members

Non-members of a dynamic zone should not be allowed to loot npcs inside
it. This should have been disabled for expeditions already but was still
allowed due to an oversight (or live behavior changed). This is less
critical for shared tasks since members can be added and removed at will
without leaving a dz but still an important feature.

* Change load where criteria

* Increase task completion emote column size

* Use eqstr for task item reward message

* Implement radiant and ebon crystal rewards

This adds reward columns for radiant and ebon crystals to the tasks
table and updates task description serialization

* Send task completion emote before rewards

This matches live and makes it a little easier to see item rewards when
tasks have a long completion emote. This also changes it to send via the
same normal message opcode that live uses.

* Do not send a shared task in completed task history

* Allow EVENT_TASK_STAGE_COMPLETE for quest goals

This invokes event_task_stage_complete for task elements flagged with a
quest controlled goal method. It should be expected behavior that a
completed task stage always fires this event even if a quest controls it

* Add SyncSharedTaskZoneClientDoneCountState

* Swap return for continue in this case

* Formatting

* Simplify

* Formatting

* Formatting

* Formatting

* Remove errant check

* Formatting, add setter for shared tasks

* Remove debugging

* Comments in PR

* More PR follow up

* Formatting

* Cleanup

* Update packet comments

* Comments

* More cleanup

* Send command error message if not in shared task

/taskadd is the only command with this feedback on live. Newer live
clients also generate this instead of the server sending the message

* Implement expire_time on SharedTask object and add a purge on world bootup

* Comment

* Add SyncClientSharedTaskStateToLocal where clients fall out of sync and no longer have a task locally

* Clamp shared task activity updates to max done count and discard updates out of bounds

* Fix packet send

* Revert packet send

* Adjust clamping OOO for completed time check. Add completed tables to purge truncation

* Refactor kill update logic so that shared task kill updates only update one client instead of all clients

* Cleanup how we're checking for active tasks

* Forward task sets that contain shared tasks

This forwards task sets that contain a shared task to shared task
selector validation like normal task selectors

* Change eqstr for empty solo task offers

This is the message live appears to use if all task offers are filtered
out by solo task validation

* Fix max active tasks client message

This message starts at the third argument. It was maybe intended to be
an npc say message but live just sends it as a normal eqstr with the
first two arguments nulled.

* Load client task state after zoning complete

This fixes a possible race where a character removed from a shared task
while zoning would be stuck with an incorrect character activities state
after zoning was completed.

This was caused by the character loading task state to early on zone
entry but never receiving the remove player message from world since
they are missing from the world cle until zoning is completed.

Loading client state after zone connection is completed makes sure the
client has the latest state and available to the world cle

* Send message to clients removed while zoning

This message should usually only be sent to characters that were
removed from a shared task while zoning but will occur for any sync
state removals where a message wouldn't have already occured.

* Post rebase fix

* HG comment for checking active task

* Addressing HG comments around zeroing out a shared task id

* Remove errant comment

* Post rebase database manifest updates

* Update eqemu_logsys_log_aliases.h

* More rebase catches

* Bump database version for last commit

Co-authored-by: hg <4683435+hgtw@users.noreply.github.com>
2021-09-05 01:21:23 -05:00
Kinglykrab
26299354b6
[Quest API] Adds new methods to NPCs and Corpses (#1510)
- Add $npc->HasItem(item_id) to Perl.
- Add $npc->CountItem(item_id) to Perl.
- Add $npc->GetItemIDBySlot(loot_slot) to Perl.
- Add $npc->GetFirstSlotByItemID(item_id) to Perl.
- Add $corpse->HasItem(item_id) to Perl.
- Add $corpse->CountItem(item_id) to Perl.
- Add $corpse->GetItemIDBySlot(loot_slot) to Perl.
- Add $corpse->GetFirstSlotByItemID(item_id) to Perl.
- Add npc:HasItem(item_id) to Lua.
- Add npc:CountItem(item_id) to Lua.
- Add npc:GetItemIDBySlot(loot_slot) to Lua.
- Add npc:GetFirstSlotByItemID(item_id) to Lua.
- Add corpse:HasItem(item_id) to Lua.
- Add corpse:CountItem(item_id) to Lua.
- Add corpse:GetItemIDBySlot(loot_slot) to Lua.
- Add corpse:GetFirstSlotByItemID(item_id) to Lua.

These methods will allow server operators to view the loot a current has in a slot, the first slot found by item ID, count the item by ID, and see if the NPC has the item.

With that functionality you could build a custom loot system and modify loot more dynamically.
2021-08-31 00:42:08 -05:00
Michael Cook (mackal)
7a46a6595c
[Cleanup] use std::make_unique (#1259)
* Convert common/eq_limits.cpp to use make_unique

* Convert common/net/console_server.cpp to use make_unique

* Convert common/net/servertalk_client_connection.cpp to use make_unique

* Convert common/net/servertalk_legacy_client_connection.cpp to use make_unique

* Convert common/net/servertalk_server.cpp to use make_unique

* Convert common/net/websocket_server.cpp to use make_unique

* Convert common/net/websocket_server_connection.cpp to use make_unique

* Convert common/shareddb.cpp to use make_unique

* Convert eqlaunch/worldserver.cpp to use make_unique

* Convert loginserver/server_manager.cpp to use make_unique

* Convert loginserver/world_server.cpp to use make_unique

* Convert queryserv/worldserver.cpp to use make_unique

* Convert ucs/worldserver.cpp to use make_unique

* Convert world/clientlist.cpp to use make_unique

* Convert world/expedition.cpp to use make_unique

* Convert world/launcher_link.cpp to use make_unique

* Convert world/login_server.cpp to use make_unique

* Convert world/main.cpp to use make_unique

* Convert world/ucs.cpp to use make_unique

* Convert world/web_interface.cpp to use make_unique

* Convert world/zonelist.cpp to use make_unique

* Convert world/zoneserver.cpp to use make_unique

* Convert zone/client.cpp to use make_unique

* Convert zone/corpse.cpp to use make_unique

* Convert zone/dynamiczone.cpp to use make_unique

* Convert zone/expedition.cpp to use make_unique

* Convert zone/main.cpp to use make_unique

* Convert zone/mob_ai.cpp to use make_unique

* Convert zone/mob_movement_manager.cpp to use make_unique

* Convert zone/pathfinder_nav_mesh.cpp to use make_unique

* Convert zone/worldserver.cpp to use make_unique
2021-02-23 18:30:46 -06:00
hg
6c8c81f3db Move player corpses on instance shutdown
Moves corpses to graveyard when an expired instance shuts down.
Zones without a graveyard move them to non-instance version instead.

Fixes player corpses being left inside instances that expire
before graveyards process or in instances without a graveyard
2021-01-02 19:42:18 -05:00
hg
79287fc507 Require zone id to get expedition by instance id
This is a breaking api change
eq.get_expedition_by_instance_id(instance_id) is replaced with
eq.get_expedition_by_zone_instance(zone_id, instance_id)

This replaces the FindCachedExpeditionByInstanceID method of
obtaining expeditions via instance id with a new method that
requires the dz zone id as well
2020-12-30 18:47:31 -05:00
hg
f97cc7cdec Add expedition event loot api
Add SetLootEventByNPCTypeID and SetLootEventBySpawnID quest apis

These associate events with npcs or entities inside the dz to prevent
them from being looted by characters that didn't receive the event
lockout from the current expedition.

This fixes an exploit that allowed a player that already had a lockout
from another expedition being added to loot after the event is complete
2020-12-30 18:47:09 -05:00
Akkadius
51356610b2 Fix overflow issue with character corpse creation using the wrong struct in allocation 2020-08-21 00:23:13 -05:00
Akkadius
3f62da4573 Merge branch 'master' of https://github.com/EQEmu/Server into integration/multi-tenancy-expansions-repository 2020-05-23 22:33:34 -05:00
KimLS
2fbd5aaccc Rename namespace EQEmu to namespace EQ (so we don't have two similar but different namespaces anymore) 2020-05-17 18:36:06 -07:00
Akkadius
373fb3f0e7 Decouple zone calls, cleanup logic 2020-04-19 04:36:39 -05:00
Akkadius
ca49f3902f Migrate getZoneX calls and npc types calls [skip ci] 2020-03-12 02:27:09 -05:00