- Joined
- May 9, 2014
- Messages
- 1,819
A largely compact resource that incorporates and handles common CC effects swimmingly well, drastically reducing the groundwork of the mapper. It has already seen usage in other approved spell resources (mostly Hero Concepts), so approval for this bundle is merely a formality.
There are certain parts of the code that could use some refactoring for clarity that I didn't notice before. Nothing too major though, so it should be easy to deal with.
Utilities library:
Utilities library:
- In the function
GetEnemyUnitsInRange(player enemyOf, real x, real y, real aoe, boolean structures, boolean magicImmune)
, multiple versions of what is functionally the same loop exists. At the cost of evaluating the provided boolean values once, you can rewrite it as the following:
JASS:loop set w = FirstOfGroup(h) exitwhen w == null if IsUnitEnemy(w, enemyOf) and UnitAlive(w) and /* */ (structures or (not IsUnitType(w, UNIT_TYPE_STRUCTURE))) and /* */ (magicImmune or (not IsUnitType(w, UNIT_TYPE_MAGIC_IMMUNE))) then call GroupAddUnit(g, w) endif call GroupRemoveUnit(h, w) endloop
- The same applies for the function
UnitDamageArea(unit source, [...], boolean structures, boolean magicImmune, boolean allies)
. You can rewrite it like this:
JASS:loop set w = FirstOfGroup(h) exitwhen w == null if (UnitAlive(w) and w != source) and /* */ (allies or IsUnitEnemy(w, enemyOf)) and /* */ (structures or (not IsUnitType(w, UNIT_TYPE_STRUCTURE))) and /* */ (magicImmune or (not IsUnitType(w, UNIT_TYPE_MAGIC_IMMUNE))) then call UnitDamageTarget(source, w, damage, true, false, atkType, dmgType, null) endif call GroupRemoveUnit(h, w) endloop
- Same point applies once more for the function
UnitDamageCone(unit source, ...)
.
- These are quite minor, so feel free to implement changes how you see fit.
- In the static method
CrowdControl.onEvent(integer key)
, the nested loop inside the if-then block can be moved outside, to reduce the number of indentations.
Code:private static method onEvent takes integer key returns nothing local integer i = 0 local integer next = -1 local integer prev = -2 set count = count + 1 if count - CROWD_CONTROL_KNOCKUP >= RECURSION_LIMIT then set count = count - 1 set .key = key endif loop exitwhen type[key] == next or (i - CROWD_CONTROL_KNOCKUP > RECURSION_LIMIT) set next = type[key] // The following block below might appear to be a messy implementation of a continue statement, because it is. // The inner loop's presence will guarantee that control will be restored to the outer loop upon exiting. loop if event[next] != null then call TriggerEvaluate(event[next]) endif if type[key] != next then set i = i + 1 exitwhen true endif exitwhen next == prev call TriggerEvaluate(trigger) if type[key] != next then set i = i + 1 set prev = next endif exitwhen true endloop endloop set count = count - 1 set .key = key endmethod
Status:
- Approved
Version Reviewed:
- 1.0