Pet modifier
This commit is contained in:
parent
0d9ec1913d
commit
ed1e696eb5
4 changed files with 67 additions and 6 deletions
41
Roll.lua
41
Roll.lua
|
|
@ -4,6 +4,7 @@
|
|||
AltSystem = AltSystem or {}
|
||||
|
||||
local pendingRollType = nil -- "attack" or "defense"
|
||||
local pendingPetRoll = nil -- { rollType, mainRollValue } when awaiting pet/summon roll
|
||||
|
||||
-- Get the TRP3 character first name, falling back to the WoW unit name
|
||||
local function GetCharacterName()
|
||||
|
|
@ -65,6 +66,7 @@ end
|
|||
|
||||
-- Perform a roll: triggers the WoW native /roll 20 command
|
||||
function AltSystem:PerformRoll(rollType)
|
||||
pendingPetRoll = nil
|
||||
pendingRollType = rollType
|
||||
RandomRoll(1, 20)
|
||||
end
|
||||
|
|
@ -74,6 +76,20 @@ local rollListener = CreateFrame("Frame")
|
|||
rollListener:RegisterEvent("CHAT_MSG_SYSTEM")
|
||||
|
||||
rollListener:SetScript("OnEvent", function(self, event, message)
|
||||
-- Phase 2: waiting for pet/summon roll result (1-5)
|
||||
if pendingPetRoll then
|
||||
local petRoll = message:match("rolls (%d+) %(1%-5%)")
|
||||
if not petRoll then return end
|
||||
|
||||
local petValue = tonumber(petRoll)
|
||||
local info = pendingPetRoll
|
||||
pendingPetRoll = nil
|
||||
|
||||
AltSystem:CalculateAndDisplayResult(info.rollType, info.mainRollValue, petValue)
|
||||
return
|
||||
end
|
||||
|
||||
-- Phase 1: waiting for main roll result (1-20)
|
||||
if not pendingRollType then return end
|
||||
|
||||
-- Match the roll result pattern: "PlayerName rolls X (1-20)"
|
||||
|
|
@ -84,11 +100,18 @@ rollListener:SetScript("OnEvent", function(self, event, message)
|
|||
local rollType = pendingRollType
|
||||
pendingRollType = nil
|
||||
|
||||
-- If pet/summon is enabled, trigger a second roll (1-5)
|
||||
if AltSystem.State.petSummonEnabled then
|
||||
pendingPetRoll = { rollType = rollType, mainRollValue = rollValue }
|
||||
RandomRoll(1, 5)
|
||||
return
|
||||
end
|
||||
|
||||
AltSystem:CalculateAndDisplayResult(rollType, rollValue)
|
||||
end)
|
||||
|
||||
-- Calculate the final result based on the roll type and selected modifiers
|
||||
function AltSystem:CalculateAndDisplayResult(rollType, rollValue)
|
||||
function AltSystem:CalculateAndDisplayResult(rollType, rollValue, petRollValue)
|
||||
-- Critical rolls bypass normal calculation
|
||||
if rollValue == 1 then
|
||||
if AltSystem.ResultText then
|
||||
|
|
@ -134,9 +157,11 @@ function AltSystem:CalculateAndDisplayResult(rollType, rollValue)
|
|||
|
||||
local isBaseRoll = skill and skill.name == "Base roll"
|
||||
|
||||
local petMod = petRollValue or 0
|
||||
|
||||
if rollType == "attack" then
|
||||
-- Attack Roll = roll + skill modifier + item modifier
|
||||
total = rollValue + skillMod + itemMod
|
||||
-- Attack Roll = roll + skill modifier + item modifier + pet/summon modifier
|
||||
total = rollValue + skillMod + itemMod + petMod
|
||||
|
||||
if not isBaseRoll then
|
||||
breakdown = breakdown .. "\nSkill: " .. FormatModifier(skillMod)
|
||||
|
|
@ -146,6 +171,10 @@ function AltSystem:CalculateAndDisplayResult(rollType, rollValue)
|
|||
breakdown = breakdown .. " | Item: " .. FormatModifier(itemMod)
|
||||
table.insert(modifiers, { name = item and item.name or "Item", value = itemMod })
|
||||
end
|
||||
if petMod ~= 0 then
|
||||
breakdown = breakdown .. " | Pet: +" .. petMod
|
||||
table.insert(modifiers, { name = "Pet", value = petMod })
|
||||
end
|
||||
breakdown = breakdown .. "\n|cffffd100Attack Total: " .. total .. "|r"
|
||||
|
||||
elseif rollType == "defense" then
|
||||
|
|
@ -154,7 +183,7 @@ function AltSystem:CalculateAndDisplayResult(rollType, rollValue)
|
|||
local defenseMod = defense and defense.modifier or 0
|
||||
local shieldMod = state.shieldEnabled and AltSystem.Data.ShieldModifier or 0
|
||||
|
||||
total = rollValue + skillMod + itemMod + defenseMod + shieldMod
|
||||
total = rollValue + skillMod + itemMod + defenseMod + shieldMod + petMod
|
||||
|
||||
if not isBaseRoll then
|
||||
breakdown = breakdown .. "\nSkill: " .. FormatModifier(skillMod)
|
||||
|
|
@ -170,6 +199,10 @@ function AltSystem:CalculateAndDisplayResult(rollType, rollValue)
|
|||
breakdown = breakdown .. " | Shield: " .. FormatModifier(shieldMod)
|
||||
table.insert(modifiers, { name = "Shield", value = shieldMod })
|
||||
end
|
||||
if petMod ~= 0 then
|
||||
breakdown = breakdown .. " | Pet: +" .. petMod
|
||||
table.insert(modifiers, { name = "Pet", value = petMod })
|
||||
end
|
||||
breakdown = breakdown .. "\n|cff00ccffDefense Total: " .. total .. "|r"
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue