Some help with reserrecting an old addon - human form

Hi Guys,
I have a Worgen char, and I’m trying to make it so out of combat it transforms into a human form. This macro code works well to do this:
/castsequence reset=combat Two Forms,null
So I have found a old addon nodogsallowed ( no dogs allowed) on curseforge that seems to do all the pre-req checks, but the main peice of code that did the transform

function NDA_bindings()
	SetOverrideBindingSpell(btn,false,"BUTTON1",Two_Forms)
	CombatTracker = 1

no longer works.
The question is, in the addon lua, how can I make the function execute my macro (or cast sequence) that works in place (/castsequence reset=combat Two Forms,null), so something like this:

function NDA_bindings()
	/castsequence reset=combat Two Forms,null
	CombatTracker = 1

or even (as the name of my macro is ‘Human’)

function NDA_bindings()
	runmacro("Human")
	CombatTracker = 1

I’ll keep researching but I hope someone can help me with this hopefully easy fix.

Since they moved from file paths to file Ids, PlayerModel:GetModel() no longer works (you should be getting an error). You will need to use GetModelFileID() and map that against a table of valid ids for forms you want action.

local ModelFileIDs = { [1000764]="Human Female", [1011653]="Human Male" } 
local NDA_ModelName = NoDogsAllowed:GetModelFileID()
if ModelFileIDs[NDA_ModelName] == nil

This stuff is really hard to debug for a noob.
None of the old scripts work for this.
Let me ask a better question - what is the easiest way to active the below code whenever the walk forward key is pressed please?

/castsequence reset=combat Two Forms,null

Maybe in a addon format?

My bad, I left the [] from the ModelFileID table.

The whole .lua file would be:

-- NoDogsAllowed brought to you by Spinalcrack of US-Sargeras

local _ , race = UnitRace("player")
local Two_Forms = GetSpellInfo(68996)
local CombatTracker = 1
local NDA_Event = CreateFrame("Frame")
local NoDogsAllowed = CreateFrame("PlayerModel", nil, UIParent)
local btn = CreateFrame("Button", "NDA_Button");
local ModelFileIDs = { [1000764]="Human Female", [1011653]="Human Male" }

if race ~= "Worgen" then
	-- No point in running on non-worgren
	NoDogsAllowed_OnLoad = function() end
	return
else
	NDA_Event:RegisterEvent("UNIT_MODEL_CHANGED")
	NDA_Event:RegisterEvent("PLAYER_LOGIN")
	NDA_Event:RegisterEvent("PLAYER_REGEN_ENABLED")
	NDA_Event:RegisterEvent("PLAYER_REGEN_DISABLED")
end

function NDA_bindings()
	SetOverrideBindingSpell(btn,false,"BUTTON1",Two_Forms)
	CombatTracker = 1
end

function NDA_CheckForm()
	if CombatTracker == 1 then 
		ClearOverrideBindings(btn) 
		return
	else
		NoDogsAllowed:SetUnit("player")
--		local NDA_ModelName = NoDogsAllowed:GetModel()
--		if strfind(NDA_ModelName,"\human") == nil
		local NDA_ModelName = NoDogsAllowed:GetModelFileID()
		if ModelFileIDs[NDA_ModelName] == nil
			then
				-- You are in Worgen Form
				NDA_bindings()
				
			else 
				-- You are in Human Form
				ClearOverrideBindings(btn)
		end  
	end		
end

function NDA_Event:OnEvent(event, arg1, ...)
	if event=="PLAYER_REGEN_DISABLED" then CombatTracker = 1 end
	if event=="PLAYER_REGEN_ENABLED" then CombatTracker = 0 end

	local InCombat = UnitAffectingCombat("player")	
	if InCombat ~= true and CombatTracker == 0 then NDA_CheckForm() end
end

function NoDogsAllowed_OnLoad(self)
	-- Keeping this here for future stuff
end

NDA_Event:SetScript("OnEvent", NDA_Event.OnEvent)
6 Likes

Ah top man!
It works wonderfully!
Thank you so much :slight_smile:

Hi, so does the addon/macro work? I also want to automatically go into human form out of combat

Hi! this was working until the shadowlands pre patch event started, is there any new code that needs to be changed? or was it just me? can someone help me pls, i loved to go back to human in out of combat.

Hi! this was working until the shadowlands pre patch event started, is there any new code that needs to be changed? or was it just me? can someone help me pls, i loved to go back to human in out of combat. pls can you save my worgen from this curse again :smiley:

Its a pretty interesting addon, but why not just add /cancelform to a mount macro? The first thing i do whenever i’m done fighting is mount up.

I don’t actually use the addon so you’ll need to describe what it’s doing (or not doing) that it did pre-Shadowlands.