1. Are you planning to upload your awesome spell or system to Hive? Please review the rules here.
    Dismiss Notice
  2. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  3. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still haven't received your rank award? Then please contact the administration.
    Dismiss Notice
  4. Ride into the sunset with the 32nd Modeling Contest. The contest is optionally paired. Best of luck, people!
    Dismiss Notice
  5. This adventure has come to an end. Congratulate our heroes in the 16th Mini Mapping Contest Results.
    Dismiss Notice
  6. From the gates of hell, the 5th Special Effect Contest Results have emerged.
    Dismiss Notice
  7. Race against the odds and Reforge, Don't Refund. The 14th Techtree Contest has begun!
    Dismiss Notice
  8. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

Zwiebelchen's Threat System 2.7

Submitted by Zwiebelchen
This bundle is marked as approved. It works and satisfies the submission rules.
What is a threat system?
Basicly, it's a system that takes over Mob AI. The unit that dealt the most damage to the creep will be the one that gets attacked.
Although that is only half the truth, it should be enough to get the idea.

If you ever played World of Warcraft (as a mapper, you should have), chances are you know what a threat system does.
And this is an almost perfect replica of it.


Requirements:
- vJass preprocessor

What is different from this to other systems:
- First of all, this system is almost (if not completely) 100% fail-safe. It does checks on killed AND removed units and clears them automaticly.

- Second, it features a unique camp squad functionality, which ensures that units that are preplaced in camps will always attack and return together. If units return, they will be rendered invulnerable until they reach their original camp position again. If they can not reach their camping position within a certain duration, they will get instantly teleported back.
Like this, there is almost no more kiting or bug-abusing possible, as it was with other systems.

- Third: It does not block other Spellcasting systems. The system will only give orders to units, if the unit either has no order (i.e. auto-engage) or an "attack" order. If you want the unit to use a spell instead of attacking, you can do so whenever you want without having to fear interference of the system.
In fact, there is a special function provided so that people can create their own Spell-AI directly in a custom trigger

- Fourth: It provides a lot of useful functions and Getters (Like ApplyHealThreat or GetCombatState), to make triggering spells even more easy.

- Fifth: It is, by far, the fastest and most flexible threat system out there. I completely remastered the system from the last version and the entire script (except for certain enumerations that can not be avoided) is now O(1) complexity.


Version history:
2.7
- Fixed a bug that sometimes did not properly render units in-combat if pulled again right after returning to camp position

2.6
- Added a new function: ZTS_GetCombatTime, which returns the time an npc unit is currently in combat; returns 0 if the unit is currently out of combat or returning to camp position; does not work on player units

2.5
- Added a new boolean to the ZTS_AddThreatUnit command that determines wether the added unit shall be added to already fighting Creep Camps or only to non-fighting Creep Camps - this is interesting when you create encounters that summon units as you usually don't want those summoned units to create their own Creep Camp but want them to be added to the Boss' Creep Camp
- Fixed a small bug that sometimes caused linked Creep Camps

2.4
- Fixed a bug sometimes rendering units permanently invulnerable, when registering a unit in close range to currently retreating units

2.3
- Changed TriggerActions of dynamic triggers to TriggerConditions, to avoid nasty action leak
- Fixed GetThreatUnitAmount (did not return the correct value)

2.2b
- fixed a small logic bug with GetThreatUnitAmount and GetThreatUnitPosition

2.2
- Now uses "smart" order instead of "attack" to issue attack orders ... it turned out that the "smart" order returns false if the unit can not reach the target (for example when rooted) - weird, as it doesn't work for "attack" for some reason
- because of that, the AddRootAbility function and the Range Setter and Getters were removed, as they have become obsolete

2.1b
- fixed a small logical bug with GetCombatState sometimes returning a false positive

2.1
- rebuilt Update function to avoid some useless enumerations - depending on the number of PlayerUnits registered, the system should now be MULTIPLE TIMES faster - As a side effect, I could also remove some useless variables

2.0
- Initial release

Comments & Discussion:

Why hashtables instead of global arrays and structs?
- hashtables are not limited in terms of max size, unlike and array of structs with a unit array, which reaches the 8000 limit very fast ... this was basicly the most important point on that decision
- hashtables are more flexible and easier to use (Flush functions, etc.)
- hashtables were benchmarked to be only 60-80% slower than getting UnitUserData alone

Where is the sort function?
- version 2.0 and higher does not use sorting anymore; instead, when threat is applied to a unit, it uses an insertion method to keep the order of the list

What is new compared to pre 2.0 versions?
- Aside from the fact that the system now is a dozen times faster than before, I also improved the AI by using the "smart" instead of "attack" order. It turned out that - in a weird way - "smart" is indeed smarter than other orders, as it returns false if the unit can't reach the target (i.e. because of root)
- There is now a way to directly get an Order event by the threat system, to make creating spell-AI easier.

Does it matter how many units are registered to the system at the same time?
- In terms of speed, no; it only affects memory usage, but that should not have an impact on game performance at all, even with tousands of units registered - only the number of currently fighting units affects runtime

I still do not really understand how to use the system...
- just check the demo map and you'll get the idea

Keywords:
threat, aggro, wow, world of warcraft
Contents

Threat System v2.7 (Map)

Reviews
Moderator
17:56, 17th Jan 2010 TriggerHappy: Very good, and you know what my suggestions are. This can be approved in it's current state, though.
  1. Zwiebelchen

    Zwiebelchen

    Joined:
    Sep 17, 2009
    Messages:
    6,828
    Resources:
    12
    Models:
    5
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    JASS:
    4
    Resources:
    12
    If you ask me, displaying the threat and stuff has nothing to do with the system itself. The getters for writing a module like that are there. It should be no problem for any decent triggerer out there to create something like that.

    I simply do not want to implement a graphical thing like that to the system, because people usually want to customize their game interface to their liking.
     
  2. Forgotten_Warlord

    Forgotten_Warlord

    Joined:
    Nov 6, 2009
    Messages:
    1,379
    Resources:
    38
    Models:
    34
    Icons:
    4
    Resources:
    38
    ok lol.
    Then I will need to learn vjass :p
     
  3. Zwiebelchen

    Zwiebelchen

    Joined:
    Sep 17, 2009
    Messages:
    6,828
    Resources:
    12
    Models:
    5
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    JASS:
    4
    Resources:
    12
    Version 2.4 now available.
     
  4. Noobsmoke

    Noobsmoke

    Joined:
    Nov 20, 2007
    Messages:
    631
    Resources:
    1
    Spells:
    1
    Resources:
    1
    i want a GUI one :D
     
  5. Zwiebelchen

    Zwiebelchen

    Joined:
    Sep 17, 2009
    Messages:
    6,828
    Resources:
    12
    Models:
    5
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    JASS:
    4
    Resources:
    12
    There's no way to do something like this in GUI.
     
  6. Nyrano

    Nyrano

    Joined:
    Jan 20, 2010
    Messages:
    3
    Resources:
    0
    Resources:
    0
    1st: Your system still pwns!
    2nd: It seems that when you die at some creep (triggered with this system) it resets normal, but when you die for a second time at that same creep (lets say, a bossfight), it does NOT reset.

    Are you aware of that? I'm experiencing issues with bossfights in my map, when you come back for a second try (and you die again), the boss doesn't reset at all and just stays at the same amount of health.

    EDIT: NEVERMIND, Solved it.

    I did not know you had to add the units again when they died once.
     
  7. Noobsmoke

    Noobsmoke

    Joined:
    Nov 20, 2007
    Messages:
    631
    Resources:
    1
    Spells:
    1
    Resources:
    1
    Are you sure about this ? i mean ... i really want to see a system like that in GUI :grin:
     
  8. Noobsmoke

    Noobsmoke

    Joined:
    Nov 20, 2007
    Messages:
    631
    Resources:
    1
    Spells:
    1
    Resources:
    1
    GUI vesion ? i don't use Jass ...
     
  9. Forgotten_Warlord

    Forgotten_Warlord

    Joined:
    Nov 6, 2009
    Messages:
    1,379
    Resources:
    38
    Models:
    34
    Icons:
    4
    Resources:
    38
    Well I doubt ur going to get ur GUI one from here since he hasnt responded to ur other posts... btw... whats wrong with this, just throw it into ur map :D
     
  10. Zwiebelchen

    Zwiebelchen

    Joined:
    Sep 17, 2009
    Messages:
    6,828
    Resources:
    12
    Models:
    5
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    JASS:
    4
    Resources:
    12
    I agree on that one. You don't need to know about vJass to use the system; just copy and paste it into a trigger and use the functions provided as custom script. You can also check the demo spells in the map, if you got trouble with that - or ask in the trigger help forum.
     
  11. Zwiebelchen

    Zwiebelchen

    Joined:
    Sep 17, 2009
    Messages:
    6,828
    Resources:
    12
    Models:
    5
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    JASS:
    4
    Resources:
    12
    New version! 2.5 now has the AddThreatUnit command changed to also accept a boolean that determines, wether the unit shall be added to an already fighting Creep Camp or not.

    This is usually only interesting for summoned units. In theory, you don't want (in-fight) summoned units to create their 'own' camp group. You want them to be added to the boss, so they don't return when they have killed all units on their threat list.
    You might ask now why this shouldn't be the case for non-summoned units. The reason is easy:
    Lets say you pull a Pack A some meters back to where a dead Pack B was. A unit of Pack B respawns right into Pack A's combat. In this case you don't want the respawned unit to now be added to Pack A, but a seperate group, as then - in case the Packs defeat their opponent - both packs would be "linked", although they shouldn't, obviously, as they have different spawning places.

    Sounds complicated, I know, but in the end it comes down to this:
    Units that are summond in fight should have this boolean set to true. In all other situations, you should go with false.

    Also, I fixed a very small bug with the old AddThreatUnit command that could lead to "linked" creep camps. Please update to 2.5 if you used 2.4!
     
  12. kStiyl

    kStiyl

    Joined:
    Oct 23, 2011
    Messages:
    180
    Resources:
    1
    JASS:
    1
    Resources:
    1
    Seems to bug when I use entangling roots on a ZTS_registered unit. The unit won't return to its original position; it just stands there doing nothing.
     
  13. Zwiebelchen

    Zwiebelchen

    Joined:
    Sep 17, 2009
    Messages:
    6,828
    Resources:
    12
    Models:
    5
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    JASS:
    4
    Resources:
    12
    Can you give more specific information on what you were doing?
    If you outrange the entangled unit properly, it should be teleported back to its original position after like 10 seconds. Of course it won't "walk" back until the entangling roots are gone.
     
  14. kStiyl

    kStiyl

    Joined:
    Oct 23, 2011
    Messages:
    180
    Resources:
    1
    JASS:
    1
    Resources:
    1
    If I entangle the enemy and run out of its "acquire range" the creep does not reset but instead just goes into sleep without reseting its hp. (After this happens, even if I outrange the creeps, they won't reset. I have to aggro them out of sleep again, drag around a bit then they would finally reset)

    Also, it isn't exactly entangling roots; just a modified ensnare with roots effect
    Acquire range, along with creep camp cells? seems to interfere a lot with the system

    *edit

    I think there are also many ways to abuse this system. One is to have a ranged dps who can generate top agro, and have other people block the creep's path by standing next to each other.
    Maybe you should add a feature so that if a creep cannot get to his top threat target in X second, maybe it should attack next highest threat unit or closest unit
     
    Last edited: Nov 12, 2011
  15. Zwiebelchen

    Zwiebelchen

    Joined:
    Sep 17, 2009
    Messages:
    6,828
    Resources:
    12
    Models:
    5
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    JASS:
    4
    Resources:
    12
    So the creep was put to sleep by wc3?
    Well in that case, it's not really a bug with the system. When the creep is asleep, it obviously just stands still and therefore will not be outranged properly. Prevent your creeps from sleeping at night and it should be fine. I can not do something about that in the system, because I don't know what people want to do in their map. But from what you told me, this is clearly not a bug with the system, just a problem with creep sleeping infight.

    I really suggest removing and altering anything that can interfere with the system, as mentioned in the documentation. Increase the gameplay camp AI constants like return range, decrease the camp radius, increase the returning time, etc ... and of course sleeping creeps won't help too.


    I know about this, but unfortunately, I can not do anything about this. This timer thing wouldn't be an appropriate solution ... what if you want to kite the mob around (legally with slow abilities, not by blocking its moves)? With this timer thing, that wouldn't be possible anymore.

    I simply suggest reducing the collision size of units in your map if you got trouble with blocking.
     
  16. kStiyl

    kStiyl

    Joined:
    Oct 23, 2011
    Messages:
    180
    Resources:
    1
    JASS:
    1
    Resources:
    1
    Thanks for reply. Decreasing camp radius helped me a little! Rep to you for making an awesome system ><
     
  17. Zwiebelchen

    Zwiebelchen

    Joined:
    Sep 17, 2009
    Messages:
    6,828
    Resources:
    12
    Models:
    5
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    JASS:
    4
    Resources:
    12
    Just check the documentation commented out in the script. I listed all game constants that you are required to change in order to make the system work properly.
     
  18. Sunchips

    Sunchips

    Joined:
    Jul 23, 2009
    Messages:
    872
    Resources:
    123
    Models:
    112
    Icons:
    4
    Packs:
    7
    Resources:
    123
    Tried using in my map but then I cant start the map \o/

    Using NewGen WE

    Edit: I realized it might be because I need vJass preprocessor... cant find it though, anyone has a good link?
     
  19. Zwiebelchen

    Zwiebelchen

    Joined:
    Sep 17, 2009
    Messages:
    6,828
    Resources:
    12
    Models:
    5
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    JASS:
    4
    Resources:
    12
    If you got newgen, then you should be fine.
    Maybe give a little bit more detail on the problem? How can you not start the map?
    Does it load and crash? Does it not load? The system itself is and should be fine, numerous players are using it (including me).
     
  20. Sunchips

    Sunchips

    Joined:
    Jul 23, 2009
    Messages:
    872
    Resources:
    123
    Models:
    112
    Icons:
    4
    Packs:
    7
    Resources:
    123
    I tried to implement this into the map (auto copy variables check) and when I tried to start the game via test map it opens wc3 and puts me on main menu. If I try to manually go to single player -> custom game and start the map it does the same. Return me to main menu.

    I thought it could have been something with JASS helper so I saved the map and then tried starting it. Didn't work :/ thx in advance

    Edit: Is it GUI friendly? I dont really understand what I'm supposed to change in the script etc
    Edit: Sorry I'm stupid now I found the manual. I will read it through and see if I understand.
    EDIT: Still won't work. It gives me a list of infinite errors :/
    [​IMG]