mirror of
https://github.com/opentibiabr/canary
synced 2026-08-16 06:26:09 -04:00
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. |
||
|---|---|---|
| .. | ||
| lua_api.d.lua | ||
| lua_api.json | ||
| lua_api.md | ||
| lua_api_quality_baseline.json | ||