Commit graph

730 commits

Author SHA1 Message Date
Eduardo Dantas
b0092a9b87
feat(pvp): add Expert PvP world type and combat rules (#4033)
Add Expert PvP world type and combat rules

This commit adds Expert Open PvP support to Canary as an explicit world type through worldType = expert-pvp.

The implementation introduces a dedicated ExpertPvp component for Expert specific combat, relation, field, movement, collision, and marking rules. Existing combat, spell, tile, player, game, and protocol code remain as thin integration points, while the Expert PvP decisions live under src creatures players components pvp.

This keeps the new behavior isolated from the existing world types and avoids spreading Expert PvP specific rules across unrelated systems.

The existing PvP world type handling was also clarified. retro-pvp is now the explicit Retro Open PvP value, while pvp remains supported as a compatibility alias for retro-pvp. no-pvp and pvp-enforced remain outside the Expert PvP decision path.

Main world type changes

• Adds worldType expert-pvp

• Makes retro-pvp the explicit Retro Open PvP config value

• Keeps pvp as a compatibility alias for retro-pvp

• Changes the default config value from pvp to retro-pvp

• Removes the old toggleServerIsRetroPVP config option

• Updates Lua helpers so IsRetroPVP reads the world type string

• Adds IsExpertPVP for Lua scripts

• Keeps no-pvp and pvp-enforced behavior outside the Expert PvP component

The ExpertPvp component centralizes relation classification and decision making for the new world type. It evaluates PvP mode, actor and target relation, combat action type, field ownership, side effects, player collision, and viewer specific situation marks.

The component covers relations such as self, access players, party allies, guild allies, war enemies, direct attackers, protected ally attackers, direct targets, skulled targets, neutral players, monsters, player summons, and NPCs.

Main Expert PvP rules included

• Dove mode behavior

• White Hand behavior

• Yellow Hand behavior

• Red Fist behavior

• Direct combat decisions

• Rune target decisions

• Area spell decisions

• Summon combat decisions

• Field step decisions

• Field damage decisions

• Player walkthrough decisions

• Pathfinding probe decisions

• Viewer specific field visual decisions

• Viewer relative creature situation marks

Combat integration now asks ExpertPvp before allowing Expert PvP relevant actions. This applies to direct attacks, runes, aggressive area spells, mana and health combat, conditions, dispels, default combat actions, and field damage.

When Expert PvP handles an action, it can allow or block the action and apply the correct side effects. These side effects include fight state, PZ lock behavior, skull actions, square feedback, and unjustified kill tracking where applicable.

Secure mode behavior is handled through the Expert PvP relation rules instead of the older broad secure mode check. This allows secure mode retaliation without applying unjustified protection zone locks in cases where the Expert PvP relation allows the response.

Magic Wall and Wild Growth now carry Expert PvP cast time context. When Expert PvP is enabled, these fields are created as safe field variants and receive owner context so the server can evaluate relation dependent behavior later.

Magic Wall and Wild Growth changes

• Stores the field owner context when the rune is cast

• Stores the owner PvP mode at cast time

• Tracks owner targets and attackers at cast time

• Uses safe visual field items as the base item in Expert PvP

• Resolves viewer specific appearance through protocol serialization

• Evaluates collision and pathfinding from the field context

• Evaluates field stepping side effects through ExpertPvp

• Prevents Expert PvP owned safe fields from being removed like regular no-pvp safe fields

• Keeps normal no-pvp behavior for non Expert PvP worlds

Tile and pathfinding logic now consult ExpertPvp for Expert owned fields. This allows Magic Wall and Wild Growth to appear or behave differently depending on the viewer and the PvP relation, while still using the existing movement and tile query paths as the final authority.

Player walkthrough and body blocking were updated so Expert PvP can decide whether a player can walk through another player outside legacy safe zones. Party, guild, war, attacker, protected ally, and target relations are used to keep collision behavior aligned with Expert PvP hand modes.

PvP situation tracking was added so player relations can affect persistent creature marks. The server can now send viewer relative creature marks for the current client profile and refresh visible marks when relevant state changes.

Situation mark updates happen when needed for events such as party changes, guild changes, attacked player tracking, player removal, and visible relation changes.

Protocol changes

• Adds ExpertPvpModeByte as a protocol feature flag

• Enables Expert PvP mode byte support for the Tibia 11.00 profile

• Keeps Tibia 11.00 on the verified four byte Set Tactics layout

• Keeps current 15.25 on its verified three byte tactics layout

• Defaults unsupported profiles safely to Dove mode

• Avoids appending speculative PvP mode bytes to the current 15.25 profile

• Sends Expert PvP controls only when the protocol profile supports them

• Sends viewer relative creature marks only through supported packet layouts

The current 15.25 profile keeps its verified tactics payload layout and does not receive a speculative extra PvP byte. This prevents client desync or crash risk. Unsupported profiles are forced safely to Dove when Expert PvP is enabled but the protocol cannot represent the mode.

Player state now includes a dedicated PvP component. The selected Expert PvP mode is stored on the player and persisted to the database.

Persistence and database changes

• Adds PlayerPvp component

• Adds player getPvpMode and setPvpMode support

• Saves expert_pvp_mode during player save

• Loads expert_pvp_mode during player load

• Adds players.expert_pvp_mode to schema.sql

• Bumps database version to 59

• Adds migration 59 for the players.expert_pvp_mode column

• Skips the migration safely if the column already exists

Lua API support was expanded so scripts can inspect PvP state and attach field context where needed.

Lua API changes

• Adds Player getPvpMode

• Adds Player hasAttacked

• Adds Item setExpertPvpFieldContext

• Updates generated Lua API documentation

• Updates Magic Wall and Wild Growth scripts to attach Expert PvP field context

The PR also updates blessing and death loss behavior to use the new Retro PvP world type detection instead of the removed toggleServerIsRetroPVP config. This keeps existing Retro PvP behavior while moving the decision to the explicit world type model.

Additional behavior covered

• Party relation handling

• Guild relation handling

• War enemy relation handling

• Skull relation handling

• Aggressor relation handling

• Protected ally relation handling

• Field ownership behavior

• Viewer specific field visuals

• Body blocking and player collision

• Situation marks and persistent creature marks

• Defensive PZ lock behavior

• Secure mode retaliation behavior

• Blessing cost and Twist of Fate behavior under Retro PvP detection

Out of scope

• Frag sharing

• player_kills.weight schema changes

• Debug commands

• Unrelated PvP features

• Broad behavior changes to existing world types

Documentation and tests

• Adds Expert PvP implementation roadmap documentation

• Adds Expert PvP porting plan documentation

• Links the new documentation from the systems overview

• Documents the behavioral contract

• Documents the implementation roadmap

• Documents the in game regression matrix

• Adds Expert PvP unit coverage

• Adds protocol profile coverage for Expert PvP mode support

• Adds regression scenarios for all world types

Validation performed

• Built canary target

• Built canary_ut target

• Built canary_it target

• Expert PvP and protocol profile tests passed with 49 of 49 tests

• Full unit binary passed with 311 of 311 tests

• Integration binary passed with 40 of 40 tests

• Manual scenarios were exercised during implementation

• Tested secure mode retaliation

• Tested defensive PZ lock behavior

• Tested Magic Wall and Wild Growth cast time relations

• Tested viewer specific visuals and collision

• Tested situation marks

Test configuration

• Platform Windows x64

• Compiler Microsoft Visual C plus plus 19.44

• Protocol coverage Tibia 11.00 and current 15.25 profiles

Known validation note

Two isolated CTest invocations terminated during global teardown after their test bodies passed. The same behavior reproduces on the main baseline. Running the unit suite in one process passes all 311 tests.

Overall this commit adds Expert Open PvP as a gated world type with dedicated relation based combat and field rules. It keeps existing world types protected from Expert PvP behavior, persists the selected PvP mode, supports protocol safe PvP mode handling, updates Lua APIs and documentation, and adds regression coverage for the new rules.
2026-08-10 18:42:55 -03:00
mimus-assa
b045dfab02
fix: storage keys that do not exist, silently dropping quest progress (#4064)
Bug Fixes:
- Improved quest, mission, outfit, cooldown, and progress tracking for more reliable activity completion.
- Fixed Giant Smith Hammer quest completion and NPC mission checks.
- Corrected ritual task and fame-point progress tracking.
- Fixed Dream Courts encounter cooldowns, transformations, teleport access, and quest progression.
- Improved mission-state tracking and corrected several quest progression issues.
2026-08-06 13:27:35 -03:00
Eduardo Dantas
44a2e1227f
fix(monster): refresh renamed creatures (#4054)
Bug Fixes:
- Fixed monster name change updates so clients reliably refresh the displayed monster for all visible spectators.
- Improved /setmonstername behavior with stricter name parsing/validation, accurate counting of renamed monsters, and clearer player feedback (including cases where no monsters are found or all already match).
2026-08-06 13:17:32 -03:00
mimus-assa
8c06104604
fix: Prey Wildcard store offers should be 1x10 and 5x50 coins (#4045)
Bug Fixes:
- Adjusted the quantities included with the “Prey Wildcard” offers to reflect the correct amounts.
2026-08-06 13:15:34 -03:00
mimus-assa
30e022c1da
fix: !autoloot all was unreachable, "all" left commented out in validValues (#4067) 2026-08-05 08:25:51 -03:00
mimus-assa
8f72a201bb
fix: familiar spells unlearnable — NPCs sell a spell name that does not exist (#4046) 2026-07-25 11:20:51 -03:00
Eduardo Dantas
a879c9312e
fix(audit): repair invalid item ranges and reduce storage false positives (#4034) 2026-07-13 22:02:47 -03:00
Eduardo Dantas
bc826add94
perf: improve lifetime scheduling and monster AI hot paths (#4023)
Optimize monster hot paths and deferred gameplay scheduling

This commit implements the next slice of the performance and lifetime roadmap for the Canary creature and monster hot paths.

The focus is to reduce dispatcher pressure, async task fanout, spectator churn, pathfinding churn, and target list lifetime risk under monster-heavy workloads while keeping player visible gameplay behavior intact.

The change keeps combat and condition handling on the serial dispatcher path, but moves delayed monster post think work into a budgeted DeferredGameplay lane. This allows monster follow-up work to make progress without competing directly with the most sensitive gameplay operations on the main dispatcher.

Creature async work is now sliced through bounded buckets. This limits how much async creature work can be emitted at once and helps avoid large bursts of scheduled tasks. The deferred async flag clearing behavior is preserved, so creatures are not incorrectly considered ready for another async pass before the deferred work has actually completed.

Monster movement AI refreshes are now coalesced. Instead of scheduling repeated movement refreshes for the same monster in a burst, the system can merge pending refresh intents and execute them more controllably. This reduces redundant dispatcher work and helps monster-heavy scenarios avoid excessive task fanout.

Target lifetime handling was also improved. Monster target tracking now keeps player count bookkeeping balanced even when weak target references expire. This reduces the risk of monsters staying active because an expired player target was removed from the target list without updating the related active player count.

Pathfinding and tile lookup hot paths now reuse scoped floor cursors. This avoids repeated cursor setup work during repeated spectator and pathfinding operations while keeping the safe lifetime boundaries documented. The reuse is scoped so temporary lookup state does not escape beyond the valid operation window.

Benchmark-only monster stress options were added to make heavy monster workloads easier to test. These settings are intended for profiling and stress validation only, not normal production gameplay. A startup warning appears when stress settings are enabled, so operators do not accidentally run production servers with benchmark behavior active.

The change also preserves current client protocol compatibility details unrelated to the monster performance work, but necessary to keep behavior stable. The current 15 13 screenshot event payload encoding and level percent protocol gates remain preserved.

Main changes included in this commit

• Adds benchmark-only monster stress configuration flags

• Adds a startup warning when benchmark monster stress flags are enabled

• Allows stress scenarios such as keeping monsters active for benchmark purposes

• Allows monster versus monster target selection only through the benchmark stress configuration

• Slices creature async work through bounded buckets

• Preserves deferred async flag clearing behavior

• Routes delayed monster post think work through the budgeted DeferredGameplay lane

• Keeps combat and condition execution serial on the dispatcher

• Coalesces monster movement AI refreshes to reduce redundant scheduling

• Improves monster target tracking and target list lifetime safety

• Keeps target player count bookkeeping balanced when weak target references expire

• Improves monster idle behavior under expired target cleanup cases

• Reuses scoped floor cursors for pathfinding and tile lookup hot paths

• Documents the safe lifetime boundaries for cursor reuse

• Reduces spectator and pathfinding churn in monster-heavy workloads

• Preserves the current 15 13 screenshot event payload encoding

• Preserves level percent protocol gates

• Fixes the special Starving Wolf trap interaction

• Adds dispatcher queue latency logging to help monitor responsiveness

• Documents performance and lifetime roadmap evidence

• Documents validation assumptions for production-like scenarios and stress test scenarios

Runtime behavior

Monster AI and creature scheduling should now produce less dispatcher pressure during dense monster activity. Delayed monster post-think work is handled through the deferred gameplay lane with a budget, rather than being allowed to fan out into unbounded dispatcher pressure.

Player visible gameplay contracts remain intact. Combat and conditions continue to run through the serial dispatcher path, so the change does not intentionally reorder sensitive gameplay effects.

Movement and auto-walk behavior should be more predictable under load because repeated monster movement AI refreshes can be coalesced rather than stacking redundant work. Monsters should still move and react, but the refresh work is scheduled with less unnecessary churn.

Target tracking is safer when targets disappear. If a player target expires through a weak reference cleanup path, the monster target side bookkeeping is also updated, so idle and active state decisions are not based on stale player counts.

Stress testing behavior

The new monster stress flags are benchmark-only controls. They make it easier to reproduce monster-heavy workloads for profiling and validation, but they are not intended as normal server behavior.

When these flags are enabled, the server emits a startup warning to make the configuration's non-production nature clear.

Validation performed

• Static validation with git diff check HEAD 5 HEAD

• Reviewed production-like behavior assumptions for dispatcher and monster scheduling

• Reviewed stress test behavior assumptions for monster heavy workloads

• Follow up commits addressed validated comments around target count cleanup

• Follow-up commits addressed trap handling comments

• Follow-up commits addressed async scheduling comments

• Follow up commits addressed documentation comments

Overall, this commit improves the performance and lifetime safety of the Canary monster and creature hot paths. It reduces unnecessary async fanout dispatcher pressure, movement refresh churn, and pathfinding lookup overhead while preserving the serial gameplay contracts that matter for players.
2026-07-07 19:23:39 -03:00
Eduardo Dantas
ab863b04d2
feat: update current client 15.25 compatibility (#4020)
Update current client protocol compatibility to 15.25 byte contract

This commit updates the current client runtime profile to match the Tibia 15.25 byte contract and keeps the changes behind explicit runtime protocol feature flags.

The goal is to make the current client able to log in and keep running without message boundary debug errors while preserving the existing multiprotocol structure. This is a compatibility update focused on sending and consuming the bytes expected by the current client. It does not implement the full gameplay systems behind the new official windows dialogs rewards shops progression or balance features.

The current profile now enables versioned payload flags for the confirmed 15.25 differences. These flags gate the new packet shapes so the modern client can receive the expected payloads while older profiles do not automatically inherit incompatible message layouts.

The update also adds minimal byte compatible shims for new current client module windows and side dialogs. Taskboard and Soul Seals now have official client packet shims that respond with structurally valid empty windows where the gameplay system is not fully implemented yet. This keeps the client protocol stable without pretending that the complete feature set exists server side.

Several current client payloads were aligned with the 15.25 format. This includes resource balances graphical effects vocation specific data skill wheel weapon proficiency game events quest related payloads store summary parsing and related request parsers.

Main changes included in this commit

• Updates the current client runtime profile to the 15.25 byte contract

• Adds runtime feature flags for confirmed current client payload differences

• Gates 15.25 specific packet layouts behind explicit ProtocolFeature flags

• Adds support for official skill wheel payload differences

• Adds support for official weapon proficiency payload differences

• Adds support for graphical effect source byte differences

• Adds support for official vocation specific player data

• Adds support for official Taskboard packet family handling

• Adds support for official Soul Seals packet family handling

• Adds minimal byte compatible Taskboard shims for the current client

• Adds minimal byte compatible Soul Seals shims for the current client

• Adds explicit parsers for several previously unhandled current client opcodes

• Aligns resource balance request parsing with the current client payload

• Aligns graphical effect payloads with the current client format

• Aligns vocation specific data payloads with the current client format

• Aligns skill wheel payloads including quest bonus and gem list layout

• Aligns weapon proficiency payloads including detail list support

• Aligns game event payloads and related request handling

• Expands GameStore parsing for offer descriptions and events

• Adds stricter packet parsing and trailing byte handling where needed

• Improves protocol aware login logging with richer asset signature details

• Adds a god level protocol probe command for live protocol and message testing

• Documents the 15.25 compatibility scope and versioned payload flags

Protocol profile changes

The current profile mask now includes the new protocol feature flags required by the 15.25 byte contract. These flags allow the server to describe exactly which current client payloads are active instead of tying every behavior only to a raw client version number.

This keeps the compatibility layer safer for multiprotocol support because older profiles can continue using their own packet shapes while the current profile enables the official 15.25 payload differences.

Module shim changes

Taskboard support was added as a minimal official client shim. The server consumes the expected current client packet shape and returns structurally valid empty Taskboard windows. This keeps the client UI protocol satisfied while leaving the full Taskboard gameplay implementation for future work.

Soul Seals support was also added as a minimal official client shim. The server reads the expected request data validates the packet shape and responds with a structurally valid empty placeholder response. This prevents message boundary issues for the current client without implementing the complete Soul Seals system yet.

Payload compatibility changes

The current client expects several packet layouts that differ from older protocol profiles. This commit updates the server to match those confirmed layouts for the active current profile.

The affected areas include skill wheel payloads weapon proficiency details vocation specific player data resource balance requests graphical effects game events store parsing quest related payloads and related packet parsers.

These changes are focused on byte compatibility. They make the packet boundaries and payload shapes stable so the current client can operate without protocol debug breaks.

Bug fixes and robustness improvements

This commit also includes several protocol adjacent fixes found during the compatibility work. Packet parsing was made stricter in selected paths. Quest tracker validation and logging were updated. Store parser state handling was improved by avoiding shared global mutation for the default entries per page value.

The update also fixes precision and argument handling issues in related current client payload paths including level percent casting and forge skill stat argument placement.

Protocol probe tooling

A god only protocol probe command was added for live protocol testing. This gives maintainers a way to test selected protocol and message flows in game while keeping the command restricted to god group access.

The probe tool includes built in probes and file driven local probes, making it useful for reproducing current client packet behavior without exposing the tool to normal players.

Documentation changes

The systems documentation was updated with the 15.25 compatibility scope and multiprotocol feature notes. The documentation explains that this PR is a byte compatibility update and not a full gameplay implementation for every new current client window or system.

It also documents the versioned payload flags so future protocol updates can continue using explicit feature gated packet differences instead of mixing incompatible layouts into shared paths.

Validation performed

• Tested current client login locally

• Tested key current client UI surfaces locally while fixing reported client debug cases

• Confirmed fixes for skill wheel payload boundaries

• Confirmed fixes for character stats payload boundaries

• Confirmed fixes for store summary payload boundaries

• Confirmed fixes for defense stats payload boundaries

• Confirmed fixes for game event payload boundaries

• Confirmed fixes for graphical effect payload boundaries

• Confirmed fixes for related current client request parsers

• Full compile and build validation was not run

Known scope limitation

This commit intentionally does not implement the full gameplay systems behind the new current client windows dialogs rewards shops progression systems or balance features.

The purpose is to stabilize the message shape first. Full gameplay behavior can be implemented later on top of the now compatible packet structure.

Overall this commit brings the current client protocol path in line with the Tibia 15.25 byte contract. It adds explicit feature gated compatibility for confirmed payload differences introduces minimal shims for new official client windows improves parser coverage and documents the compatibility boundary while preserving the existing multiprotocol architecture.
2026-07-06 20:42:40 -03:00
Eduardo Dantas
82b4778a5f
feat(protocol): add runtime multiprotocol client profiles (#4009)
Add runtime multiprotocol support to Canary

This commit adds runtime multiprotocol support to Canary without changing the compiled CLIENT VERSION target and without requiring separate ports for each supported client version.

The server can now resolve and apply protocol behavior at runtime through explicit protocol profiles. This allows modern clients legacy old protocol clients and extended legacy client variants to be supported through the same server entry point while keeping each protocol family isolated behind its own transport login and asset compatibility rules.

The implementation separates the protocol stack into smaller contracts instead of relying on one shared hardcoded flow. Transport behavior connection startup behavior profile metadata login parsing and session hints are now handled by dedicated components. This makes the multiprotocol path easier to reason about and safer to extend when adding more client families later.

Transport handling is now described through TransportCodec and TransportProfile. These components define TCP framing checksum behavior XTEA payload layout and compression behavior for each protocol family. Legacy clients no longer inherit the modern post 14 05 framing rules by accident and can use their own packet layout where required.

The first game socket decision is now handled through InitialConnectionBehavior. This controls the expected transport the handshake flow the challenge layout and the profile expected for the connection. This is important because old protocol clients and modern clients do not share the same login handshake assumptions.

ProtocolProfile now describes the client version wire family RSA family feature flags item mapper policy and asset signatures for each supported profile. This gives the server an explicit model for the client family being served instead of relying only on the compiled CLIENT VERSION or manual server side assumptions.

The login flow was also split into separate account login and game login layouts. This avoids forcing old protocol and modern webservice flows to share fragile hardcoded parsing logic. Each login family can now use the layout expected by that protocol path.

ProtocolSessionHintStore was added so the account login flow can hint the later game connection automatically. This avoids requiring administrators to manually choose a profile or run separate ports for different supported client versions. When a safe hint exists the game connection can reuse it to select the correct protocol behavior.

Supported profiles covered by this commit

• Current modern Canary client profile

• Tibia 11 00 old protocol profile

• CipSoft 8 60 compatible profiles

• Canary extended 8 60 asset profile

The current modern Canary profile remains the default when no safe legacy hint exists. Policy can block a detected profile but policy does not choose legacy framing by itself. This keeps profile selection explicit and prevents configuration policy from silently forcing the wrong transport behavior.

For the extended 8 60 client path the server resolves the profile from protocol version and asset signatures instead of requiring a separate port or manual profile selection. This allows a single runtime server path to distinguish between compatible legacy variants when the client package and assets provide enough information.

The related client packages are available in the latest dudantas tibia client release 15 11 c9d1cf. Prepared clients support the matching extended dat and spr workflow as well as config ini based local profile configuration.

The intended outdated client asset workflow is also documented. Compatible dat and spr files can be exported from a modern asset source using the Assets Editor changes. Original CipSoft clients can be extended or edited using the Tibia Extended Client Library workflow. This allows the project to keep a single asset source of truth and export compatible packages for the extended 8 60 and 11 00 client paths.

Main changes included in this commit

• Adds runtime multiprotocol profile support

• Keeps the compiled CLIENT VERSION target unchanged

• Avoids separate ports per client version

• Adds TransportCodec and TransportProfile for framing checksum XTEA payload layout and compression behavior

• Adds InitialConnectionBehavior for game socket startup handshake challenge layout and expected profile selection

• Adds ProtocolProfile for client version wire family RSA family feature flags item mapper policy and asset signatures

• Splits account login and game login parsing into separate protocol aware layouts

• Adds ProtocolSessionHintStore so login can hint the game connection automatically

• Keeps the modern Canary profile as the default fallback

• Supports Tibia 11 00 through the old protocol path

• Supports CipSoft 8 60 compatible profiles

• Supports the Canary extended 8 60 asset profile

• Resolves the extended 8 60 profile from protocol version and asset signatures

• Keeps legacy clients on their own framing challenge and payload layouts

• Prevents policy configuration from silently choosing legacy framing by itself

• Enables legacy protocol support by default in the distributed config

• Improves protocol aware login logging with richer asset signature details when available

• Adds documentation for adding and maintaining runtime protocol profiles

• Links the multiprotocol documentation from the systems overview

• Expands build policy guidance so build entry points stay in sync

Validation covered by this commit

• Extended 8 60 client can log in and play with exported extended assets

• Tibia 11 00 old protocol client can log in through the old protocol path

• Modern 15 x client remains supported

• Local Windows release build completed with the Canary target

• Unit tests were added for protocol and profile resolution

• Unit tests were added for transport sizing and header behavior

• Unit tests were added for protocol session hint flows

Overall this commit introduces a runtime multiprotocol architecture for Canary while keeping the existing modern client path as the default. It adds explicit protocol profiles dedicated transport and login contracts automatic session hinting and documentation so multiple client families can be supported safely through one server runtime without changing the compiled client target or splitting traffic across separate ports.
2026-07-01 13:14:58 -03:00
Eduardo Dantas
5ee38ce90a
feat: 15.13 npc module protocol and update NPC Lua scripts (#3982)
This commit standardizes NPC configuration across multiple Lua files by adding explicit profession and speechBubble properties to each affected NPC config.

The goal is to make each NPC role clear in the script itself and keep speech bubble behavior consistent between the server NPC configuration and the client presentation layer. NPCs now explicitly declare whether they are normal NPCs or trader NPCs, instead of relying on implicit or inconsistent defaults.

The profession value was added under npcConfig flags for all affected NPCs. Each NPC now uses either normal or trader depending on its expected role. This makes the NPC intent easier to read and helps avoid ambiguity when future scripts or client side behavior depend on the configured profession.

The speechBubble value was also added to each NPC config. Normal NPCs use SPEECHBUBBLE_NORMAL and trader NPCs use SPEECHBUBBLE_TRADE. This keeps the in game dialogue bubble aligned with the NPC role and improves consistency in how NPCs are displayed to players.

Main changes included in this commit

• Adds explicit profession configuration to affected NPC Lua files

• Uses normal for regular NPCs

• Uses trader for shop and trade related NPCs

• Adds explicit speechBubble configuration to affected NPC Lua files

• Uses SPEECHBUBBLE_NORMAL for normal NPC dialogue presentation

• Uses SPEECHBUBBLE_TRADE for trader NPC dialogue presentation

• Keeps NPC role information visible directly in each NPC config

• Reduces reliance on implicit default behavior

• Improves consistency between NPC server configuration and client side speech bubble rendering

• Aligns server NPC configs with the related client support added in tibia client PR 18

• Preserves existing NPC behavior while making the configuration more explicit

This is a configuration standardization change. It does not rework NPC logic or change the data access flow. The intended behavior remains the same, but the role and speech bubble metadata are now declared consistently so both server and client can interpret NPC presentation more reliably.
2026-07-01 10:12:58 -03:00
Paco
def12a7fcd
feat: add configurable retro spell learning system (#3971)
Add a config boolean to enable the retro spell learning system.

Main changes:
- Add retro spell learning support behind a configuration option.
- Update all spells to respect the new config.
- Update spell-related NPCs to handle the learning system according to TibiaWiki behavior.
- Update Dawnport NPCs for the retro spell learning flow.
- Update the Rookgaard Oracle to handle Monk vocation selection.

Validation:
- Debugged and tested on tibiatales.com using the Canary/TFS Crystal server distribution.

This allows servers to enable classic spell-learning behavior via config while keeping the existing spell behavior configurable.
2026-05-29 12:17:08 -03:00
LeoTK
bd5b40225a
feat: add test server NPC with dynamic shop support (#3954)
Add a Test Server NPC designed for development and test environments, with a shop list that can be automatically updated from items.xml.

Main changes:
- Add a dedicated Test Server NPC.
- Populate the NPC shop from items.xml instead of relying only on a manually maintained item list.
- Provide visible inventory with buy and sell interactions.
- Keep the NPC useful for test servers where items, prices, and equipment lists change often.

Test server commands:
- Add promotion support.
- Add and remove coins.
- Grant money.
- Adjust skills.
- Change vocation.
- Change level and experience.
- Reset the character.
- Grant outfits with addons.
- Grant mounts.
- Apply missing blessings.

Shop validation:
- Update shop price warning logic to exclude the Test Server NPC.
- Avoid false warnings when this NPC exposes items with special test-server pricing.
- Adjust the cheaper-item warning check so test-server shop behavior does not affect normal shop validation.

This makes test server setup easier by providing one NPC for equipment testing, character setup, currency adjustments, cosmetics, mounts, blessings, and dynamic shop updates without affecting normal NPC price validation.
2026-05-22 23:28:28 -03:00
Eduardo Dantas
e99d283ebf
perf: improve Canary startup loading performance (#3968)
Improve Canary startup performance by reducing Lua/script loading cost, optimizing map parsing and cache construction, and lowering repeated lookup/allocation work during monster spawn startup.

Measured impact:
- Loaded modules and scripts wall time improved from about 54s to 1.516s best observed, with 2.997s in the latest captured run, about 94% to 97% less wall time.
- Scripts::loadScripts dropped from 17.60% to 9.31% to 15.00% across later captures.
- luaL_loadfile dropped from a dominant original hotspot to 1.60% to 2.80%.
- getLuaBytecodeCacheEntry appeared at only about 0.49% to 0.51%, showing cache lookup is cheap compared to the old file-load path.
- CanaryServer::loadMaps dropped from 65.59% after the Lua improvements to 57.68% in the latest capture.
- IOMap::parseTileArea dropped from 59.58% to 53.87%.
- MapCache::setBasicTile dropped from 24.96% to 20.50%.
- phmap::try_emplace for cached basic tiles dropped from 7.25% to 0.99%.
- MapSector::createFloor dropped from 7.17% to 5.76%.
- SpawnMonster::startup dropped from 11.74% to 9.56%.
- SpawnMonster::spawnMonster dropped from 10.64% to 9.13%.

Main changes:
- Add Windows RelWithDebInfo compiler and linker settings for useful release profiling symbols.
- Add Lua startup telemetry options and bytecode cache configuration.
- Make the Lua debug hook configurable so release profiling can avoid unnecessary hook overhead.
- Improve Lua script loading by reducing filesystem metadata work, using bytecode cache entries, loading from memory when possible, and supporting packed cache data.
- Add detailed startup timing logs for modules and datapack directories.
- Add map-load reservations after reading the map header, including cache and container reservations based on map dimensions.
- Add simple-tile and cache fast paths for common map-loading tile shapes.
- Reduce shared pointer churn in the map cache path by using raw cache pointers internally where cache ownership is already guaranteed.
- Reduce repeated sector and floor lookup work while parsing map tiles.
- Improve zone indexing and copy behavior to avoid unnecessary set copies in spawn and tile insertion paths.
- Optimize monster spawn startup by reusing resolved tile data and avoiding redundant lookups while preserving spawn behavior.
- Move broad headers into pch.hpp where appropriate to keep benefiting from the precompiled header setup.
- Add docs/maps/startup-loading-performance.md with profiling notes, decisions, results, and follow-up areas.
- Add tests for map-download helpers and weighted monster spawn selection.
- Add ignore rules for the Lua bytecode cache directory.

Notes:
- The profile captures are sampling profiles, so percentages represent sampled CPU share, not direct wall-clock speedup.
- The latest 2.997s run appears to include local machine variance, but it remains far below the original 54s baseline.
- Map loading is now the main remaining startup hotspot.
- No behavior, map semantics, or spawn semantics are intended to change.
2026-05-22 16:58:43 -03:00
Eduardo Dantas
6c6469016e
feat: add livestream broadcasting system (#3965)
Works with: https://github.com/opentibiabr/login-server/pull/31 (467af8d72f)

Add the game server side of the livestream system, allowing players to broadcast gameplay to read-only viewers and exposing active casters for external login services.

Livestream system:
- Add LivestreamManager to manage caster sessions, viewers, passwords, bans, mutes, kicks, and livestream chat.
- Add player-facing livestream talkactions through data/scripts/talkactions/player/livestream_system.lua.
- Support commands such as !livestream on, !livestream off, !livestream password, !livestream ban, and !livestream status.
- Add read-only viewer login through the normal protocol bootstrap while preserving client 15 compatibility.
- Integrate livestream state into Player and ProtocolGame.

Viewer restrictions:
- Keep livestream viewers read-only.
- Block viewer input that would move, fight, use items, send gameplay actions, or mutate the caster state.
- Preserve the normal player flow for non-livestream sessions.

Configuration:
- Add livestream configuration options to config.lua.dist.
- Wire livestream settings into the config loader.
- Add startup/runtime integration needed by the game server.

Database:
- Add active_livestream_casters so external login services can list active casters.
- Add migration data-otservbr-global/migrations/58.lua.
- Update schema.sql.
- Bump the database version to 58.

Login contract:
- External login services must use the descriptor @livestream.
- The livestream session key format is:
  @livestream
  <password>

Client 15 integration:
- Document the login.php flow for @livestream.
- List active casters from active_livestream_casters.
- Return a character list built from active casters.
- Return a clear login error when no casters are active or livestream is disabled.
- Return the expected livestream session key format for viewer login.

Compatibility:
- Keeps normal login, protocol bootstrap, and player gameplay behavior unchanged outside livestream mode.
2026-05-22 16:53:29 -03:00
Eduardo Dantas
f59ab0cffc
feat: protocol 15.11 (weapon proficiency and new imbuement scroll) (#3845)
Add the WeaponProficiency component with persistent per-weapon
progression, perk selection, experience tracking, and combat bonus
handling.

Implement serialization and deserialization for proficiency data, perk
management, active augments, stat bonuses, critical damage modifiers,
bestiary/boss/powerful foe bonuses, skill/spell percentage bonuses, and
perfect shot handling.

Also add related client support, imbuement scroll/tool flows, new items,
mounts, outfits, achievements, NPC shop updates, scheduled-save
notifications, and loot table adjustments.

Thanks to @phacUFPE and @FelipePaluco for the development base.

Client PR: https://github.com/dudantas/tibia-client/pull/17
---------

Co-authored-by: Felipe <87909998+FelipePaluco@users.noreply.github.com>
Co-authored-by: Pedro Cruz <pedro.ha.cruz2022@gmail.com>
Co-authored-by: Eduardo Dantas<eduardo.dantas@hotmail.com.br>
2026-05-21 14:34:39 -03:00
Eduardo Dantas
a365056651
perf(refactor): implement player container batch updates (#3701)
Introduce centralized BatchUpdate handling for player-owned containers so bulk item mutations can suppress intermediate container refreshes and send one final update when the outermost batch finishes.

Batch affected containers across bulk add, remove, move, stack, stash retrieve, reward/managed loot collection, store inbox delivery, forge/wheel item consumption, paginated container insertion, NPC buy/sell, and loot pouch selling paths.

Also harden related transaction flows by validating purchase constraints before mutation, skipping invalid/protected sell items, and aborting custom currency failures before removing player items.

Add Lua batch helpers and automated coverage for batch lifecycle, deduplication, nested scopes, loot sale batching, and paginated container insertion.
2026-05-21 01:26:37 -03:00
RedSTwix
5a6c896d5b
fix: add floorchange to Podzilla ramp items (#3955)
New Features:
• Expanded the ramp item selection with newly added variants featuring
directional placement properties. These items now support north, west,
east, and south orientations, providing greater building flexibility and
more comprehensive options for designing diverse game environments and
structures.
2026-05-19 02:56:41 -03:00
LeoTK
1efd58f6c4
feat(reward-bags): rebalance drop weights and add multi-open test mode (#3915)
Reward-bag drops are now controlled with per-item weights, allowing finer
difficulty tuning per reward entry while preserving legacy chance fields.

What changed:
- Implement weighted selection per item inside reward bags.
- Keep backward compatibility with legacy `chance` definitions and emit a
  one-time warning when legacy format is used.
- Add admin test mode to simulate multiple openings from a single bag open,
  with aggregated console output for drop distribution validation.
- Improve item delivery flow:
  - try backpack first;
  - fallback to store inbox when inventory cannot receive the reward;
  - improve logs and player-facing messages for no-room/inbox delivery cases.

Why:
- Gives better control over real drop difficulty for each individual item.
- Enables fast balancing/verification of target rates through repeatable
  simulations without manual open spam.
2026-05-09 11:01:15 -03:00
Copilot
d25a6572c7
fix: store purchases to combine transferable and regular Tibia Coins (#3924)
fix(gamestore): allow transferable offers to use combined coin balance

Store purchases for `CoinType.Transferable` were validating and deducting
from only one coin pool, which could reject valid purchases. Example:
200 transferable + 100 regular could not buy a 300-coin offer.

What changed:
- `canPayForOffer`:
  - for `CoinType.Transferable`, validate against the combined balance
    (`transferable + regular`) instead of transferable-only.
- `makeCoinTransaction`:
  - for `CoinType.Transferable`, consume transferable coins first, then
    consume the remaining amount from regular coins.
- Keep `CoinType.Coin` behavior unchanged (regular-only deductions).
- Keep coin transfer behavior unchanged (`parseTransferableCoins` remains
  transferable-only by design).

Behavior impact:
- Transferable-store offers now match expected wallet semantics and no
  longer fail when total balance is sufficient across both pools.

---------

Co-authored-by: Eduardo Dantas <eduardo.dantas@hotmail.com.br>
2026-05-09 08:14:48 -03:00
Eduardo Dantas
23b132a45c
fix: support explicit forge stacks for influenced monsters (#3942)
Allow influenced monsters to be configured with an explicit forge stack
when spawned from scripts or console commands. The forge setup now uses
the provided stack instead of randomizing it, while preserving the
existing random behavior when no stack is passed.

Also clean stale influenced-monster IDs before enforcing the configured
limit, handle add failures in Lua, and return an explicit boolean from
the Lua forge configuration binding.
2026-05-08 09:56:55 -03:00
RedSTwix
e4282251ad
fix: server-side quest tracker persistence (#3934)
New Features:
• Server-side quest tracker persistence with per-player options
(auto-track/auto-untrack) and safe initial-sync.

Improvements:
• Robust login/logout sync to prevent lost or empty tracker state.
• Automatic tracking/untracking pipeline with delayed, cancelable
removals.
• Tighter quest/mission progression checks and reduced tracked-quest
limits.

Stability:
• Safer protocol parsing with malformed-packet guards, expanded logging,
and message unread-byte support.
2026-05-06 22:56:15 -03:00
Eduardo Dantas
732289efaa
fix: random mount outfit crash (#3932)
Bug Fixes:
• More reliable mount handling during outfit changes: randomized mounts
now resolve to no mount when invalid/unavailable and incompatible mounts
are cleared.
• Login outfit replacement now only applies for specific looks when the
player lacks group access.
• Outfit mount compatibility is pre-evaluated to ensure accurate
validation.

Tests:
• Added unit tests for randomized-mount resolution and
mount-compatibility checks.

Chores:
  • Test target updated to include the new tests.
2026-05-04 19:18:38 -03:00
Beats
726199c5ab
fix: deplete the clicked exercise weapon, not the first in inventory (#3918)
Fixes #3855.

When a player carries multiple exercise weapons of the same type, using
the second (or any non-first) weapon on a training dummy was draining
charges from the first weapon in the inventory instead of the one the
player actually clicked.

Bug Fixes
• Improved training weapon tracking during exercise events to ensure the
weapon remains valid and properly positioned throughout the training
session.
• Training will now correctly stop if the weapon is removed or moved
during active training.
2026-05-04 08:23:42 -03:00
Beats
712030799b
fix: correct Monk avatar lookType for tier transcendence (#3921)
Fixes #3852.

• Updated the avatar appearance for Monk and Exalted Monk vocations.
2026-05-04 08:06:12 -03:00
Eduardo Dantas
48eb2d6dfc
fix: add fallback and checks when loading scheduler scripts (#3909)
This commit refactors the script loading logic in the
`EventsScheduler::loadScheduleEventFromXml()` method to improve
flexibility and error reporting. The main change is that the code now
attempts to load event scripts from an additional directory if the
script is not found in the primary location, and logs a more informative
warning message if loading fails.
2026-04-30 23:39:45 -03:00
Jonyrewind
2f58fc039c
fix: improve quest logic and world data (#3907)
feat(quests): refactor HoD teleports and add Augustin NPC

- Refactor Heart of Destruction teleport logic into a unified vortexTeleports structure
- Consolidate boss access, exits, cooldown checks, and teleport handling
- Add Augustin jeweler NPC with shop inventory, dialogue, and world spawn
- Improve Rotten Blood entrance checks and remove forced teleport-back on denial
- Adjust Candia teleport effects and behavior
- Standardize quest failure and access messages
- Increase special item transformation success rate from 10% to 50%
- Set phantasm_summon earth resistance to 100%
- Make yawno NPC stationary
- Apply minor quest, NPC, and configuration consistency fixes
2026-04-28 20:44:52 -03:00
André Morais
dcb58c42be
feat: imbuement vibrancy (#3868)
New Features:
• Added "Paralysis Deflection" imbuement category and the "Vibrancy"
imbuement in three tiers (15%, 25%, 50% paralysis removal).
• Vibrancy supports optional PvP paralysis deflection and can be applied
to boots in standard and premium variants with tiered item requirements.
• Updated many item imbuement slots to expose paralysis deflection so
Vibrancy can be equipped broadly.
---------

Co-authored-by: Eduardo Dantas <eduardo.dantas@hotmail.com.br>
2026-04-04 10:24:35 -03:00
LeoTK
eb68ed9672
fix: fiendish and influenced spawn (#3889)
New Features:
• Teleport command now cycles per-player through fiendish/influenced
forge monsters and creatures by name, with clear status messages.

Bug Fixes
• Forge population reliably clears, repopulates, and removes stale
entries each update.
• Fiendish and influenced creation respect configured limits and stop
early when full.
• Creation logic decoupled so influenced and fiendish counts update
independently and avoid improper gating.
2026-03-31 09:13:58 -03:00
Eduardo Dantas
a6c61d08a8
feat: implement player food tracking & Lua binding (#3851)
New Features:
• Food effect duration tracking added — consumable foods now create
visible active food buffs with remaining time.
• Many consumables now grant timed food effects (commonly 1 hour; select
items extend up to 24 hours).
• Character summary now lists active foods and remaining durations for
easier management.
• Various dishes updated to set or refresh their food timers when
consumed.
2026-03-12 04:05:23 -03:00
Everton Zoelner
d25e00b917
fix: enable stairs in Azzilon Castle (#3886)
• Added a new stairs item to the game.
2026-03-05 13:44:22 -03:00
Tomás Wolf
566c6aa9c1
fix: MsgContains word-boundary matching breaks NPC bank transfers (#3864)
Bug Fixes:
• NPC message parsing now enforces exact word boundaries to reduce false
keyword matches.
• Bank transfer flow more reliably captures and validates recipient
names, improving transfer prompts and error messages.

Tests:
• Added Lua test suite covering NPC messaging and word-boundary
behavior.

Chores:
• Updated CI test workflow to run Lua tests directly and improve test
execution.
2026-02-22 19:30:48 -03:00
kokekanon
2be078541f
fix: packets error hireling (0xC8 lua) in OTCR (#3870)
New Features:
• Improved OTCR client detection for more accurate compatibility checks
on affected clients.
• Expanded hireling outfit display for OTCR-compatible clients, adding
support for wings, auras, effects, and shaders in outgoing outfit
messages.
2026-02-22 19:24:37 -03:00
Everton Zoelner
ded10949d5
fix: add new item "ramp" with floor change attribute (#3866)
• Added a new "ramp" item (article "a") that enables northward floor
transitions when placed in the world.
• The item is available alongside existing items and can be used to
create multi-level navigation paths.
2026-02-19 22:40:24 -03:00
Everton Zoelner
b1e31b59e5
feat: add skill trainer item for offline skill training (#3865)
• Added a new skill trainer item that enables offline training for fist fighting and shielding skills.
2026-02-19 16:46:12 -03:00
Eduardo Dantas
d23f2c8651
fix: add starting items for Monk vocation (#3860)
New Features:
• Added MONK vocation: Players can now create characters of the new MONK
class with specialized starting equipment, including a jo staff, brass
armor set, boots, scarf, and a starter container filled with essentials
like a shield, rope, shovel, and health potions.
2026-02-18 10:36:36 -03:00
Eduardo Dantas
8f90bdb2dc
ci/cd: fix gha on main branch (#3848) 2026-02-13 01:16:45 -03:00
Eduardo Dantas
5e357d8a81
feat: add Way of the Monk quest and monk-related content (#3794)
feat: add Way of the Monk quest, monster updates, and core data improvements

This commit introduces the complete implementation of the Way of the Monk quest, along with multiple updates to monsters, bosses, items, and core gameplay data.

Quest:
• Added full quest definition for Way of the Monk, including mission flow, shrine tracking, and storage handling.
• Registered the new quest module in the quest catalog.
• Introduced new storage keys related to monk quest progression and items.
• Added a sample monk player migration (DB version 55) for testing purposes.
• Added Blue Valley to the towns list to support quest locations.

Monsters and Bosses:
• Added new monster Tame Terror Bird with complete stats, behaviors, and loot.
• Reworked Mitmah Vanguard boss with updated events, attributes, attacks, defenses, elemental modifiers, loot, and lifecycle hooks.
• Expanded loot tables for bosses such as The Brainstealer and The Monster, including monk-related items and potions.

Items and Loot:
• Updated frazzlemaw and guzzlemaw loot to drop traditional sai instead of sai.
• Added monk-related item IDs to destruction scripts and Dawnport cleanup logic.

Gameplay:
• Added Monk’s Apparition to the Soul War quest apparition list.
• Introduced a new combat formula for fist fighting skill.
• Removed legacy fist fighting attack speed configuration from server settings.

Workflow:
• Improved GitHub Actions workflow to ensure reusable checks run on the correct branch.
2026-02-12 23:03:25 -03:00
LeoTK
a82fef0af0
feat: new sounds ambient and music (#3526)
Add a zone-based ambient and music sound system with day/night support

Introduces a Lua-driven ambient and music sound system with zone triggers
and day/night variants. Adds engine and Lua APIs for ambient/music effects,
new sound enums, player methods, and protocol support. Includes admin
commands to force periods and manually trigger sounds for testing.
2026-01-30 08:20:51 -03:00
LeoTK
b05bec4aad
feat(quests): allow non-sequential quest IDs and indices (#3795)
This modification changes the quest log reading format, allowing quest logs to be created without requiring sequential indices or IDs.

For example, a quest log can contain quests with indices such as 51, 80, and 120, along with missionId and other non-sequential IDs.

This enables leaving gaps for future quests, separating custom quests from original ones, and supporting other use cases.
2026-01-12 10:07:08 -03:00
Luis Pablo
944a050ffd
feat: foxmouse mount action and change mount type (#3783) 2026-01-11 09:51:27 -03:00
Luis Pablo
d0800d49b0
fix: change spirit of purity type of mount (#3782) 2026-01-11 09:31:18 -03:00
Luis Pablo
eb782bca7e
feat: fiery horseshoe action to add mount to player (#3781) 2026-01-11 09:28:43 -03:00
Victor
52acfc7c02
fix: burst arrow attributes (#3758) 2026-01-11 09:13:02 -03:00
Eduardo Dantas
14b5b0cf8f
refactor: event callback system and update usages (#3684)
Refactor event callback dispatch and Lua invocation

Simplify Lua callback execution by removing explicit function-pointer parameters from C++ callback invocations and centralizing dispatch through the callback manager, with short-circuit behavior. Update combat callbacks to use dispatchReturnValue and change creatureOnCombat to mutate CombatDamage instead of returning tuples. Fix callback registration to be stably sorted by descending priority, enforce duplicate blocking only when skipDuplicationCheck is false, and ignore disabled callbacks or invalid script IDs. Align EventCallback construction with current usage and clean up redundant includes. Update documentation and Lua scripts to match the new callback types and argument conventions, and add unit tests covering ordering duplication rules, short-circuiting, and the damage mutation roundtrip.
2026-01-09 01:19:51 -03:00
Eduardo Dantas
907f35f904
feat: add event scheduler by json (#3085)
Add JSON JSON-based event scheduler system

Introduce a new JSON-driven event scheduler to manage in-game events more easily and flexibly. Add initial events.json data, documentation, and example scripts. Integrate event-driven effects into server gameplay logic, including login notifications, bestiary and bosstiary bonuses, forge success rate adjustments, and fast exercise handling. Ensure backward compatibility by supporting both XML and JSON schedules, with JSON loaded after scripts. Update the build configuration to require and link the nlohmann_json library, and include scheduler access in the player logic.
2026-01-08 17:21:22 -03:00
Eduardo Dantas
fec0226378
refactor: quest system to use modular catalog loading (#3763)
Refactor quest loading system for data-canary and data-otservbr-global by migrating quest definitions from a single monolithic file to modular catalog files and updating the loading logic to support this structure.

Update quest loading in data-canary/lib/core/quests.lua to use a loader module, replacing static quest definitions with dynamic loading from catalog files.

Change quest loading in data-canary/lib/core/load.lua and data-otservbr-global/lib/core/load.lua to use require instead of dofile, aligning with the new modular approach.

Add catalog init.lua files in both projects to aggregate quest modules and build the quest catalog.

Migrate existing quest definitions in data-otservbr-global into separate catalog files with full quest and mission structures.
Add an example quest catalog file to data-canary to demonstrate the new catalog format.
2026-01-06 15:12:17 -03:00
Eduardo Dantas
61d0b6e9db
refactor: add gamestore catalog modules (#3738)
This refactors a comprehensive set of modules for the GameStore system,
including constants, helpers, and parsers. The changes establish a
robust foundation for handling store offers, user actions, and
transactions in a modular and maintainable way. The most important
changes are the addition of a detailed constants file, helper functions
for offer handling, and a parser module that manages all store-related
protocol events and purchase logic.

**GameStore System Foundation**

* Added a new `gamestore.constants.lua` file containing all core
constants for the GameStore, such as offer types, sub-actions, action
types, coin types, error codes, packet codes, default values,
descriptions, and item limits. This centralizes configuration and
improves maintainability.

**Helper Functions**

* Introduced `gamestore.helpers.lua` with utility functions for
converting offer types to display types and determining if an offer
requires configuration, improving code reuse and clarity in offer
handling.

**Store Event and Purchase Parsing**

* Added `gamestore.parsers.lua` which handles all GameStore protocol
events, including opening the store, searching offers, buying offers,
transferring coins, and transaction history. This module coordinates
with helpers and senders to process requests and responses, including
error handling and purchase validation.

These changes collectively lay out the structure for a feature-rich,
extensible GameStore system, making future enhancements and debugging
easier.

---------

Co-authored-by: GitHub Actions <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-01-06 12:33:07 -03:00
Eduardo Dantas
6777872e4e
feat/improve: create "custom loot" for monsters (#3080)
This update introduces several enhancements to the loot system, allowing
for more flexible loot management across different monsters without the
need to modify each monster's individual script. A global loot option
has been added, which is disabled by default, to assign items that any
monster can drop. This feature simplifies the addition of common loot
across multiple monsters, enhancing the modularity of loot management.

The "registerLoot" function has been improved to eliminate code
duplication and enhance efficiency. The "closeContainer" function has
been updated to remove problematic code that could cause crashes when
"container" used before "erase". Additionally, a new Lua function,
"getMonsterTypeByName", has been introduced to facilitate getting
monster types.
2025-10-30 18:19:31 -03:00
James
4d9bc97e8c
fix: familiar time (#3747)
These changes make a small but significant fix to the familiar system
on player login. It ensures that the remaining familiar summon time is
never negative by clamping the value to zero. This prevents potential
issues if the stored summon time is in the past.

- Clamp `familiarTimeLeft` to zero to prevent negative values by using
`math.max(0, familiarSummonTime - os.time())` in
`familiarOnLogin.onLogin`
(`data/scripts/creaturescripts/familiar/on_login.lua`).

Resolves #3710
2025-10-27 12:23:46 -03:00