Accurate combat detection and player target tracking is among the hardest to do in color if you ask me, but applying actual game play logic to the code helps make it possible. The only issue becomes are you willing to spend the time and effort to accomplish this with code.
Originally Posted by
Dan the man
Here is what I am trying to figure out:
Do I have a bar above my head, and if so, is it mine?
Having a static box area on the main screen to search for a HP bar is your best bet, unless you can track your player's model and search a set amount above it for a HP bar. AeroLib does accomplishes both, a static area where it's expected to find your player's HP bar, or if your player's "TEntity" is defined, find your own HP bar based off that. If you're standing on the same tile as another player who is fighting, you cannot use this option and must rely on animation (pixelshift) detection, or XP bar/stat changes. And that only works if you deal damage to your target.
Am I currently hitting an enemy?
You can use XP bar/stat change to determine if you deal damage, however determining if you're at least engaged in combat with a set NPC you'll need to check if that NPC has a HP bar visible. This part would eventually require some sort of target-tracking and this is very difficult to accomplish accurately and efficiently. However if you're able to utilize a form of multi-threading in Simba (there are some plugins out there to do this) then you'll have a huge advantage in speed.
Does my enemy have another enemy under it?
Since it's impossible to simply look and determine this for a normal player, it's impossible for a color-based script to accomplish this. Your best bet is to hover the NPC and check the uptext for "... more options".
Am I about to click on an enemy that is already being engaged by another player?
Check above that target for a HP bar, or track its animation (pixel shift) for a specific amount.
How do I know when an enemy has been slain while my life bar is still present?
If your XP bar is visible, check if it has changed a given amount since you first engaged in combat with that NPC. Or, check that NPC if it has a fully red HP bar.
I know there is a few pre-made functions to get health bars in combat.simba, but I can't figure out how to manipulate and filter that data to identify which bar is which.
All help is appreciated as always
You could do something like....
Simba Code:
debugTPA(getHPBars(), '');
..to show you a TPA of the center of every HP bar visible on the main screen excluding dead HP bars. If you want to debug those use "getDeadHPBars()" instead. If you have a "TNPC" declared and set its TMSObject then you could do...
Simba Code:
debugTPA(TNPC.getAllFree(), '');
Additionally you could take a look at AeroFighter and see how combat is detected and handled in that script, along with free NPC-finding. It's fairly clean code and should be easy to follow. Hope this helps.