You're not incorrect, Lightfoot. I didn't mean to imply that you were, if I did.
I understood the OP to say that DragonTayl is attempting to replace the targeting system with a system similar to WoW, where every player has a variable to represent how important of a target that PC is to the NPC. The NPC should then always choose whomever has the highest Threat variable when they change targets.
Yes. Alternate AI is one way of handling that. However, if you want to ensure that the threat meter is respected in all instances and you are not using a custom ai hook, you would need to check every instance of DetermineCombatRound to ensure that you are passing in a valid and correct threat target. If you don't, then targets may change and use the default targeting AI because of the reason you stated in your response.
My basis for saying that targets only change when the target is invalid is from the comments in the code. Yes, there are other places where DetermineCombatRound can override the target. That's why you'd need to check them all if you used the function to pass a custom target with a custom threat system and you weren't using custom AI..... That was a very long sentence.... You quoted the part where I made that exception in my post.
continue to attack that target until it is no longer a valid target (or until you call DetermineCombatRound again with a new target).
The other events can call DetermineCombatRound with a new target.
Replacing the failed target choosing code, which I also posted above, with the threat checking code might be the best way to make a universal threat based targeting system. You can bypass the default targeting code with DetermineCombatRound, or alternate ai... Or, you can just replace it with code that works and not worry about custom ai or DetermineCombatRound.
That was my point.
Yes. Custom AI would work fine also. Just sharing different options.
It shouldn't be a problem to execute DetermineCombatRound at any time. It'll re-check all of the combat variables and re-build their action list. Although, Lightfoot is probably better than me at pointing out potential unintended effects like that.
I'm still getting back in to coding for Aurora, myself...
The other creature event scripts may still override it with calls to DetermineCombatRound, however. So, you may want to find a way to ensure that they stick to their target, or edit the other event scripts to make sure they respect your target.
Lightfoot's idea of using an ai hook could check for changed targets and re-run the custom code that way too, if you decide to go that rout.
Personally, I'd replace the target finding code with a threat based code. I'd delete their target at the begining of each round (It's just a local object on the npc) and allow the npc to re-choose their target each round to ensure that they are attacking whomever is the highest threat.
Then I'd alter the OnDamaged and OnSpellCastAt events to add points to the attackers threat when they hurt the NPC or cast offensive spells at them...
And if I wanted to get really fancy, I'd have the targetting code check for local variables on the NPC which would give that NPC a preference for killing certain classes. That way, you could have rogues tend to attack mages first unless the tank is pulling a lot of aggro....
</rambling>
Modifié par wyldhunt1, 20 décembre 2011 - 12:46 .