#Does CastFilterResultTarget() Still work?
1 messages · Page 1 of 1 (latest)
why you dont use unitfilter for this things?
1- Make sure you are using Lua abilities only.
2- Like many functions from the _Lua classes, you're not really supposed to call it, you're supposed to implement/override it in your custom class (if the ability requires custom targeting, that is).
Salinco above basically answered it, but I'd like to extend it to make it clear where those functions exist.
If you check the API:
https://moddota.com/api/#!/vscripts?search=Castfilterresulttarget
You'll see that CastFilterResultTarget is strictly under the CDOTA_Ability_Lua class, which extends CDOTABaseAbility.
What this means is that this API only exists for the lua abilities class, as it is defined there in addition to everything a "regular" ability has in terms of API.
Additionally, even if you made a lua ability, you may have not made the function, since you didn't need a cast filter (in which case it will rely on the ability KV instead). That means you may be calling an ability that does not have this API implemented, and so the code will not know what function to call. You should have an if ability.CastFilterResultTarget then check to see if the function exists. Note that I did not use : here, or called the function (omitted ()), as we are simply checking that the ability has a variable with that name there - which should only exist if a function is saved into it. Only if your if is true, then you should then go ahead and actually call the function.
CastFilterResultTarget is also Client only. Moddota API page has an error.
Actually nvm CastFilterResultTarget is weird. CastFilterResultTarget is Server only when called (e.g. ability:CastFilterResultTarget(target) == UF_SUCCESS)) but Client only when declared for custom ability: ```lua
function custom_ability:CastFilterResultTarget(target)
local default_result = self.BaseClass.CastFilterResultTarget(self, target)
if ... then
return UF_SUCCESS
end
return default_result
end
Oh, thank you guys. This helps a lot.