Recent Topics

Ads

WSCT replacement

Here you can post addons, or anything related to addons.

Moderators: Management, Web Developer

Forum rules
Before posting on this forum, be sure to read the Terms of Use
User avatar
xruptor
Posts: 111

Re: WSCT replacement

Post#41 » Sun Sep 27, 2020 12:37 pm

Phantasm wrote:
Sun Sep 27, 2020 7:25 am
Any chance to add combat flag to that addon, it would completely let me remove WSCT from addons.
It's not perfect but it still utilizes the built in Warhammer event handlers.

OPEN combattextnames.lua

Find the following:

Code: Select all

function CombatTextNames.Initialize()
    -- hooks
    EA_System_PointGainEntry.SetupText =
        CombatTextNames.HookPointGainTextScaler(
            EA_System_PointGainEntry.SetupText)

    if CombatTextNames.Settings.ResetPositionOnLOS then
        EA_System_EventTracker.Update = CombatTextNames.HookLOSPositioner(
                                            EA_System_EventTracker.Update)
    end

    -- REPLACEMENTS
    EA_System_EventText.AddCombatEventText = CombatTextNames.AddCombatEventText
    EA_System_EventEntry.SetupText = CombatTextNames.SetupText
    EA_System_EventTracker.InitializeAnimationData =
        CombatTextNames.InitializeAnimationData

    EA_System_EventEntry.m_Template = "CombatTextNames_Window_EventTextLabel"
    EA_System_PointGainEntry.m_Template =
        "CombatTextNames_Window_EventTextLabel"
end
Replace with this

Code: Select all

function CombatTextNames.Initialize()
    -- hooks
    EA_System_PointGainEntry.SetupText =
        CombatTextNames.HookPointGainTextScaler(
            EA_System_PointGainEntry.SetupText)

    if CombatTextNames.Settings.ResetPositionOnLOS then
        EA_System_EventTracker.Update = CombatTextNames.HookLOSPositioner(
                                            EA_System_EventTracker.Update)
    end

    -- REPLACEMENTS
    EA_System_EventText.AddCombatEventText = CombatTextNames.AddCombatEventText
    EA_System_EventEntry.SetupText = CombatTextNames.SetupText
    EA_System_EventTracker.InitializeAnimationData =
        CombatTextNames.InitializeAnimationData

    EA_System_EventEntry.m_Template = "CombatTextNames_Window_EventTextLabel"
    EA_System_PointGainEntry.m_Template =
        "CombatTextNames_Window_EventTextLabel"
		
	RegisterEventHandler(SystemData.Events.PLAYER_COMBAT_FLAG_UPDATED, "CombatTextNames.PLAYER_COMBAT_FLAG_UPDATED")
end

local combatcount = 0
function CombatTextNames.PLAYER_COMBAT_FLAG_UPDATED()
  combatcount = combatcount + 1
  if combatcount >= 2 then
    combatcount = 0
    if GameData.Player.inCombat then
	  CombatTextNames.AddCombatEventText(GameData.Player.worldObjNum, L"+Combat", GameData.CombatEvent.INCOMING_MISS, 0)
    else
	  CombatTextNames.AddCombatEventText(GameData.Player.worldObjNum, L"-Combat", GameData.CombatEvent.INCOMING_MISS, 0)
    end
  end
end

find the following

Code: Select all

function CombatTextNames.AddCombatEventText(hitTargetObjectNumber, hitAmount,
                                            textType, abilityID)
    -- skip incoming events if they're toggled off
    if (hitTargetObjectNumber == GameData.Player.worldObjNum) and
        ((hitAmount < 0 and not CombatTextNames.IncomingDamageEnabled) or
            (hitAmount > 0 and not CombatTextNames.IncomingHealsEnabled) or
            (hitAmount == 0 and not CombatTextNames.IncomingMissesEnabled)) then
        return
    end

    if hitAmount ~= 0 and
        (math.abs(hitAmount) < CombatTextNames.Settings.MinHitAmount) then
        return
    end

    local data = GetAbilityData(abilityID)

    -- The SetupText function is going to receive only eventData.amount member.
    -- So we replace eventData.amount with a table that contains all the data we
    -- need. That is, we add ability name there. Doing things the "proper" way
    -- would require replacing more EA code, I'd rather avoid this.
    local eventData = {
        event = COMBAT_EVENT,
        amount = {
            hit = hitAmount,
            name = data.name,
            abilityID = abilityID,
            iconNum = data.iconNum
        },
        type = textType
    }

    if (EA_System_EventText.EventTrackers[hitTargetObjectNumber] == nil) then
        local newTrackerAnchorWindowName =
            "EA_System_EventTextAnchor" .. hitTargetObjectNumber
        CreateWindowFromTemplate(newTrackerAnchorWindowName,
                                 "EA_Window_EventTextAnchor",
                                 "EA_Window_EventTextContainer")
        local tracker = EA_System_EventTracker:Create(
                            newTrackerAnchorWindowName, hitTargetObjectNumber)
        EA_System_EventText.EventTrackers[hitTargetObjectNumber] = tracker

        -- For CombatTextNames.HookLOSPositioner, mark tracker as attached:
        tracker.attachedToObject = true
        tracker.timer = 0
    end

    EA_System_EventText.EventTrackers[hitTargetObjectNumber]:AddEvent(eventData)
end

replace with this

Code: Select all

function CombatTextNames.AddCombatEventText(hitTargetObjectNumber, hitAmount,
                                            textType, abilityID)
											
	local eventData = {}
	
	if type(hitAmount) == "number" then									
		-- skip incoming events if they're toggled off
		if (hitTargetObjectNumber == GameData.Player.worldObjNum) and
			((hitAmount < 0 and not CombatTextNames.IncomingDamageEnabled) or
				(hitAmount > 0 and not CombatTextNames.IncomingHealsEnabled) or
				(hitAmount == 0 and not CombatTextNames.IncomingMissesEnabled)) then
			return
		end

		if hitAmount ~= 0 and
			(math.abs(hitAmount) < CombatTextNames.Settings.MinHitAmount) then
			return
		end
		
		local data = GetAbilityData(abilityID)

		-- The SetupText function is going to receive only eventData.amount member.
		-- So we replace eventData.amount with a table that contains all the data we
		-- need. That is, we add ability name there. Doing things the "proper" way
		-- would require replacing more EA code, I'd rather avoid this.
		eventData = {
			event = COMBAT_EVENT,
			amount = {
				hit = hitAmount,
				name = data.name,
				abilityID = abilityID,
				iconNum = data.iconNum
			},
			type = textType
		}
		
	else
	
		eventData = {
			event = COMBAT_EVENT,
			amount = {
				hit = 0,
				name = hitAmount,
				abilityID = 0,
				iconNum = 0
			},
			type = textType
		}
	
	end


    if (EA_System_EventText.EventTrackers[hitTargetObjectNumber] == nil) then
        local newTrackerAnchorWindowName =
            "EA_System_EventTextAnchor" .. hitTargetObjectNumber
        CreateWindowFromTemplate(newTrackerAnchorWindowName,
                                 "EA_Window_EventTextAnchor",
                                 "EA_Window_EventTextContainer")
        local tracker = EA_System_EventTracker:Create(
                            newTrackerAnchorWindowName, hitTargetObjectNumber)
        EA_System_EventText.EventTrackers[hitTargetObjectNumber] = tracker

        -- For CombatTextNames.HookLOSPositioner, mark tracker as attached:
        tracker.attachedToObject = true
        tracker.timer = 0
    end

    EA_System_EventText.EventTrackers[hitTargetObjectNumber]:AddEvent(eventData)
end
That should do it. The combat alert will have a zero in the front but who cares as long as you can see your state on/off. If for some reason it's not working, you may need to have EnableAbilityNames enabled. Since I'm sending the combat stance event as a ability name.

Ads
User avatar
Phantasm
Posts: 172

Re: WSCT replacement

Post#42 » Sun Sep 27, 2020 1:47 pm

Thanks a lot for help. I did everything in post above and it works like a charm:)

User avatar
xruptor
Posts: 111

Re: WSCT replacement

Post#43 » Mon Sep 28, 2020 1:30 am

Phantasm wrote:
Sun Sep 27, 2020 1:47 pm
Thanks a lot for help. I did everything in post above and it works like a charm:)
Not a problem. Glad to help and happy it worked for you.

Who is online

Users browsing this forum: Akkunamo, Armin and 7 guests