Results 1 to 8 of 8

Thread: Combat detection in color

  1. #1
    Join Date
    Jan 2012
    Location
    Sydney, Australia
    Posts
    877
    Mentioned
    12 Post(s)
    Quoted
    368 Post(s)

    Default Combat detection in color

    Hi all,

    I am wanting to make a combat script that simply engages a target, waits for it to be killed then engages another target.

    I cannot seem to figure out an efficient combat detection method.

    Here is what I am trying to figure out:
    • Do I have a bar above my head, and if so, is it mine?
    • Am I currently hitting an enemy?
    • Does my enemy have another enemy under it?
    • Am I about to click on an enemy that is already being engaged by another player?
    • How do I know when an enemy has been slain while my life bar is still present?


    Forgive me if this has been asked before - did a little searching but couldn't see anything directly relevant. I have looked at a few combat scripts but haven't really been able to learn from the logic programmed in those scripts.

    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

  2. #2
    Join Date
    Jun 2012
    Posts
    4,867
    Mentioned
    74 Post(s)
    Quoted
    1663 Post(s)

    Default

    Do I have a bar above my head, and if so, is it mine?
    I think your own has a pretty reliable position so you should be able to look in your player box. For the other ones, I'd look for one adjacent to yours with a constant distance. If it moves around a lot it's probably someone else's, not the npc you're fighting.
    Am I currently hitting an enemy?
    I'd watch for experience gain.
    Does my enemy have another enemy under it?
    Not sure.
    Am I about to click on an enemy that is already being engaged by another player?
    You can probably assume anything with a healthbar is engaged.
    How do I know when an enemy has been slain while my life bar is still present?
    You'll stop gaining experience, that would be one way.

    For things like this I don't think there's any single way to know the combat state (using colour) so you need to use a variety of methods to make the best possible guess of what's happening.

  3. #3
    Join Date
    Jan 2012
    Location
    Sydney, Australia
    Posts
    877
    Mentioned
    12 Post(s)
    Quoted
    368 Post(s)

    Default

    Quote Originally Posted by Ian View Post
    I think your own has a pretty reliable position so you should be able to look in your player box. For the other ones, I'd look for one adjacent to yours with a constant distance. If it moves around a lot it's probably someone else's, not the npc you're fighting.

    I'd watch for experience gain.

    Not sure.

    You can probably assume anything with a healthbar is engaged.

    You'll stop gaining experience, that would be one way.

    For things like this I don't think there's any single way to know the combat state (using colour) so you need to use a variety of methods to make the best possible guess of what's happening.
    Thank you for the suggestions.

    Some good ideas in there.
    The experience gain might be a little unreliable as we have all experienced those consistent 0's
    That coupled with the health bar above your head being consistent might be a good approach though. If we can monitor the monsters health bar to see if it reaches 0.

  4. #4
    Join Date
    Aug 2007
    Location
    Colorado
    Posts
    7,421
    Mentioned
    268 Post(s)
    Quoted
    1442 Post(s)

    Default

    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.

    Quote Originally Posted by Dan the man View Post
    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.

    Current projects:
    [ AeroGuardians (GotR minigame), Motherlode Miner, Blast furnace ]

    "I won't fall in your gravity. Open your eyes,
    you're the Earth and I'm the sky..."


  5. #5
    Join Date
    Sep 2008
    Location
    Not here.
    Posts
    5,422
    Mentioned
    13 Post(s)
    Quoted
    242 Post(s)

    Default

    Tracking objects isn't that difficult, and has definitely been solved before: https://github.com/SRL/MSI/blob/mast...ba#L1653-L1774

  6. #6
    Join Date
    Aug 2007
    Location
    Colorado
    Posts
    7,421
    Mentioned
    268 Post(s)
    Quoted
    1442 Post(s)

    Default

    Quote Originally Posted by tls View Post
    Tracking objects isn't that difficult, and has definitely been solved before: https://github.com/SRL/MSI/blob/mast...ba#L1653-L1774
    Indeed it has, and I remember having quite the discussion with Coh3n about the subject and functionality of this within MSI. I had built some code at that time that I offered to dump into MSI for object-tracking but it never happened. This is around the time Coh3n began questioning color vs reflection within MSI; if it's available why don't we use it?

    Projects like MSI really sparked imagination and aggressively taught contributors unique ways to overcome tasks. It's amazing how much can be accomplished with tools that many reflection-scripters may believe to be primitive and outdated.

    Current projects:
    [ AeroGuardians (GotR minigame), Motherlode Miner, Blast furnace ]

    "I won't fall in your gravity. Open your eyes,
    you're the Earth and I'm the sky..."


  7. #7
    Join Date
    Jan 2012
    Location
    Sydney, Australia
    Posts
    877
    Mentioned
    12 Post(s)
    Quoted
    368 Post(s)

    Default

    Thanks for the helpful suggestions guys.

    The MSI side seems interesting. I am completely oblivious to MSI; is it color based and can it still be used?

  8. #8
    Join Date
    Jun 2012
    Posts
    4,867
    Mentioned
    74 Post(s)
    Quoted
    1663 Post(s)

    Default

    Quote Originally Posted by Dan the man View Post
    Thanks for the helpful suggestions guys.

    The MSI side seems interesting. I am completely oblivious to MSI; is it color based and can it still be used?
    Unless it's been resurrected while I've been gone it's been discontinued for quite some time now. 2010 thread here: https://villavu.com/forum/showthread.php?t=56614

    It was before my time, but I think it was a bunch of scripts glued together in a way that they could be switched between easily. And yes, 100% colour.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •