• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

In Combat System v2.0

This bundle is marked as useful / simple. Simplicity is bliss, low effort and/or may contain minor bugs.
Description:
The system allows you to check if an unit is in combat or not. Also it has events to check when unit enters or leaves combat. This system can be used to disable certain spells / items etc while an unit is in combat and enable them back when unit leaves combat.

Note :
*This system is MUI ( multi unit instanceable)



  • Combat Check
    • Events
    • Conditions
    • Actions
      • Set Combat_Found = False
      • For each (Integer Combat_Index3) from 1 to (Combat_Index2 - 1), do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Combat_Unit[Combat_Index2] Equal to Combat_Unit[Combat_Index3]
            • Then - Actions
              • Set Combat_Time[Combat_Index3] = 7.00
              • Set Combat_Index2 = (Combat_Index2 - 1)
              • Set Combat_Found = True
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Combat_Found Equal to False
        • Then - Actions
          • Unit Group - Add Combat_Unit[Combat_Index2] to Combat_Group
          • Set CombatState_Unit = Combat_Unit[Combat_Index2]
          • Set Combat_Event = 1.00
          • Set Combat_Event = 0.00
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Combat_Index2 Equal to 1
            • Then - Actions
              • Trigger - Turn on Combat Periodic <gen>
            • Else - Actions
        • Else - Actions

  • Combat Periodic
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer Combat_Index1) from 1 to Combat_Index2, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Combat_Time[Combat_Index1] Greater than 0.00
              • (Combat_Unit[Combat_Index1] is alive) Equal to True
              • (Combat_Unit[Combat_Index1] is in Combat_Group) Equal to True
            • Then - Actions
              • Set Combat_Time[Combat_Index1] = (Combat_Time[Combat_Index1] - 1.00)
            • Else - Actions
              • Unit Group - Remove Combat_Unit[Combat_Index1] from Combat_Group
              • Set CombatState_Unit = Combat_Unit[Combat_Index1]
              • Set Combat_Event = 2.00
              • Set Combat_Event = 0.00
              • Set Combat_Unit[Combat_Index1] = Combat_Unit[Combat_Index2]
              • Set Combat_Time[Combat_Index1] = Combat_Time[Combat_Index2]
              • Set Combat_Index2 = (Combat_Index2 - 1)
              • Set Combat_Index1 = (Combat_Index1 - 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Combat_Index2 Equal to 0
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                • Else - Actions



InCombat v2.0
-Entire map totally reworked
-Damage Engine added (thanks to Bribe)
-Now has events on entering and leaving combat
-Units in combat can be removed from combat manually
-It now disables spells correctly without bugging on learning
-System no longer leaks

InCombat v1.1
-Leak Fixed

InCombat v1.0
-Exemple added
-Efficiency Improved
-Leak Fixed


Visit xnoobsmokex.webs.com for other systems

Keywords:
In Combat Detectation Detector king_drift_alex noob_smoke wow system
Contents

InCombat v2.0 (Map)

Reviews
12th Dec 2015 IcemanBo: Too long as NeedsFix. Rejected. 23 Jan 2012 Bribe: This looks way, way better from the last time I reviewed your resource, and you added some good new features as well. The main thing you need to change is the indexing...

Moderator

M

Moderator

12th Dec 2015
IcemanBo: Too long as NeedsFix. Rejected.

23 Jan 2012
Bribe: This looks way, way better from the last time I reviewed your resource, and you added some good new features as well.

The main thing you need to change is the indexing. You use Paladon-esque indexing which only recycles indices after all the units leave combat, so over the course of a battle you will accumulate lots of indices making it dangerous.

I recommend you use the custom value of units provided by UnitIndexer, in combination with arrays, and then pick all units in the "in-combat" group in that "every 1 second" trigger.

You should also only fire the combat event if the damage is greater than 0, and you could also check the "starts ability effect" event and add units to the group if the spell target is an enemy.

Also, please don't advertise in large font.
 
Level 29
Joined
Mar 10, 2009
Messages
5,016
What are you talking about? This enables it so you can add your own actions after the system checks whether or not a unit is in combat, and if it is you could also disable some things. So it could be pretty useful imo. Good job.

this system allows you to check if an unit is in combat or not

too simple...
 
Level 12
Joined
Nov 20, 2007
Messages
660
so what's the purpose of this? floating text while you're in combat?...hmmm 1/5...

you are right, i didn't gave you an exeple to understand what this system does .... with this system you can disable spells when the unit is in combat (like stealth from wow or dagger from dota) and enable them after the unit is leaving combat. Why do you think this is useless ?
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
Somehow the Enter Combat -trigger looks unnecessarily comlicated. Could you explain the logic?

Is taking/dealing damage the only thing that adds you to combat? What about targeting a unit with an ability? What happens if you're surrounded by enemies while in combat and the timer runs out?

The floating texts leak.

Remove the extra and:
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • And - All (Conditions) are true
        • Conditions
          • (InCombat_Unit[InCombat_Index[1]] is in InCombat) Equal to True
          • InCombat_Time[InCombat_Index[1]] Greater than 0
          • (InCombat_Unit[InCombat_Index[1]] is alive) Equal to True
->
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (InCombat_Unit[InCombat_Index[1]] is in InCombat) Equal to True
      • InCombat_Time[InCombat_Index[1]] Greater than 0
      • (InCombat_Unit[InCombat_Index[1]] is alive) Equal to True
 
Level 29
Joined
Mar 10, 2009
Messages
5,016
asking what's the purpose of this doesnt mean that it's useless, I'm just asking coz...

1. No triggers posted
2. No concrete explanation on what's this for
example: "When a unit enters in combat it will leave after x secounds" <<< WHT is this?
3. No screenshots of 'spells disabled' while in combat (as you explained)

Lastly, stop giving examples of wow and dota coz not all people plays it...and, dont double post, use edit button...
 
Level 12
Joined
Nov 20, 2007
Messages
660
asking what's the purpose of this doesnt mean that it's useless, I'm just asking coz...

1. No triggers posted
2. No concrete explanation on what's this for
example: "When a unit enters in combat it will leave after x secounds" <<< WHT is this?
3. No screenshots of 'spells disabled' while in combat (as you explained)

Lastly, stop giving examples of wow and dota coz not all people plays it...and, dont double post, use edit button...

i will work more at this system :goblin_yeah: and i hope v1.0 will look good to everyone
 
This could bee useful, despite it's simplicity this could prove invaluable for systems like Halo
s shield, as it only regenerates after 7 seconds of not being hit, or WoW's stealth/potions/hearths/food/ect can only be used out of combat, or only once per battle. OR even simply for a passive health regen while out of combat.

The fact that this is simple should only mean it will be leakless, and lagless to be used like any other boolean check. (such as IsUnitDead(), even though there are ways around that).
 
Ah, but this is not vJASS, so people like me can use it in their map and still hit the save button.

is it that hard to download JNGP?

anyway, the idea looks fine though as Nestharus posted above, there is a better one... but I guess a GUI one, for those too lazy to download JNGP ,won't hurt...

one question, how do you make the units In combat? coz on the trigger I dont see an event (can't test the map for now...)...
 
Level 20
Joined
Jul 12, 2010
Messages
1,717
this is a pretty good system although i don't think it will be useful...
why would anybody want to disable skills while in battle? o_O
especially the ones that are created for escaping...
anyway the is good and works fine gj 5.5 :thumbs_up:
maybe the next thing you can do is to disable all combat abilities, and when you enter combat mode you can enable them ;p
 
Level 31
Joined
Jul 10, 2007
Messages
6,306
Ok, here are some issues with accuracy-


When a unit initially attacks another unit from a long distance, the attacked unit is not in combat. An attacked unit is not in combat until it can perceive an attack, which is realistically when the given attack is within the acquisition range of the unit or (if not possible) when the attack actually damages the unit.

An attack is placed into combat as soon as it attacks, but the attacked is not placed into combat until the attack is close enough or the unit is damaged.

This was one of the problems that was being addressed with PurgeandFire111's CombatState script.


Another issue is that this can be a lot better if groups aren't used, but rather an indexer.

Given the attack times are constant, I would normally recommend something similar to a timer queue, but the timers are reset every time the unit is put back into a combat state.



As such, I don't recommend use of this resource or approval of it until the accuracy issue is fixed.
 
Level 12
Joined
Nov 20, 2007
Messages
660
Ok, here are some issues with accuracy-


When a unit initially attacks another unit from a long distance, the attacked unit is not in combat. An attacked unit is not in combat until it can perceive an attack, which is realistically when the given attack is within the acquisition range of the unit or (if not possible) when the attack actually damages the unit.

An attack is placed into combat as soon as it attacks, but the attacked is not placed into combat until the attack is close enough or the unit is damaged.

This was one of the problems that was being addressed with PurgeandFire111's CombatState script.


Another issue is that this can be a lot better if groups aren't used, but rather an indexer.

Given the attack times are constant, I would normally recommend something similar to a timer queue, but the timers are reset every time the unit is put back into a combat state.



As such, I don't recommend use of this resource or approval of it until the accuracy issue is fixed.

the system is customisable ... just add this
  • Attack Check
    • Events
      • Unit - A unit Is attacked
    • Conditions
    • Actions
      • Set InCombat_Index[2] = (InCombat_Index[2] + 1)
      • Set InCombat_Time[InCombat_Index[2]] = Combat_Option1
      • Set InCombat_Unit[InCombat_Index[2]] = (Attacked unit)
      • Trigger - Run Add Combat <gen> (ignoring conditions)
      • Set InCombat_Index[2] = (InCombat_Index[2] + 1)
      • Set InCombat_Time[InCombat_Index[2]] = Combat_Option1
      • Set InCombat_Unit[InCombat_Index[2]] = (Attacking unit)
      • Trigger - Run Add Combat <gen> (ignoring conditions)
 
I have a few suggestions.

Instead of defining units as "in combat" or "not in combat", you could tag units as:
- targeted for attack
- targeting for attack
- inflicting damage heavily
- inflicting damage lightly
- inflicted by heavy damage
- inflicted by light damage

And using that information, you can tell if the unit is in Combat or not :)
 

Fud

Fud

Level 3
Joined
Aug 12, 2011
Messages
42
Ok, here are some issues with accuracy-


When a unit initially attacks another unit from a long distance, the attacked unit is not in combat. An attacked unit is not in combat until it can perceive an attack, which is realistically when the given attack is within the acquisition range of the unit or (if not possible) when the attack actually damages the unit.

An attack is placed into combat as soon as it attacks, but the attacked is not placed into combat until the attack is close enough or the unit is damaged.

This was one of the problems that was being addressed with PurgeandFire111's CombatState script.


Another issue is that this can be a lot better if groups aren't used, but rather an indexer.

Given the attack times are constant, I would normally recommend something similar to a timer queue, but the timers are reset every time the unit is put back into a combat state.



As such, I don't recommend use of this resource or approval of it until the accuracy issue is fixed.

I disagree that this should be fixed. The unit is truly in combat until he is taking damage or attacking.
For instance, if a stealth spell can only be cast when out of combat. If a long ranged missile targets a unit the unit should be able to stealth before the missile hits him. whether he should take damage is up to you but damage isn't inflicted until the target is hit why should he enter combat? It is to the advantage of people like me who are trying to create a map with WOW-like gameplay.
 
Level 10
Joined
Nov 24, 2010
Messages
546
If you ask me it's very usefull, I'm probably gonna use with "evade" system or give every hostile unit passive regeneration ability so when player run away from combat creeps will restore HP, anyway there are alot of useages for this, well done.
 
Top