• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Sc2 Shield

Status
Not open for further replies.
Level 37
Joined
Mar 6, 2006
Messages
9,243
Good job, however I'd like to point out a few things:

The floating texts. You shouldn't create/destroy them during each loop, change the text instead.

You could have a string that has as many | characters as the full bar should have. When you create the new string, you don't necessarily have to loop, you could use substring function.

Text = Full colour + substring from the ||||||| bar + |r + Empty colour + substring from the ||||||| bar + |r

You're only using two indexes of the point array, use two non-array variables instead.

In Damage trigger, you're looping through all units in the worst case scenario. I believe using a hastable would be better, especially when there are many units using the shield in the map. You could get the unit's handle and load/save the values into a hashtable.

  • For each (Integer ES_int[4]) from 1 to ES_int[1], do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • GDD_DamagedUnit Equal to ES_unit[ES_int[4]]
        • Then - Actions
          • Set ES_cd[ES_int[4]] = ES_cdtime[ES_int[4]]
        • Else - Actions
Ditch the BJ, use native instead :)
  • Custom script: call UnitRemoveAbilityBJ( 'A000', temp_unit )
Instead of the 0.01 wait, I'd like to see a timer with 0 expiration time.
 
The floating texts. You shouldn't create/destroy them during each loop, change the text instead.
~Changed. Btw, is there any advantage using this over having to destroy and re-create the text?

You could have a string that has as many | characters as the full bar should have. When you create the new string, you don't necessarily have to loop, you could use substring function.
I'll still need to use a loop to create the 'full bar'. I guess it's just easier the way I did it.

You're only using two indexes of the point array, use two non-array variables instead.
Again, is there any benefit or does it make no difference? I've seen many other systems use this.


In Damage trigger, you're looping through all units in the worst case scenario. I believe using a hastable would be better, especially when there are many units using the shield in the map. You could get the unit's handle and load/save the values into a hashtable.
Lol, sorry I'm not good with hashtables. The loop doesn't do much anyways, it is basically just resetting a few real variables and moving floating text.

Ditch the BJ, use native instead :)
Mind showing me please? I only used Custom Script there because 'temp_unit' is not an 'existing' variable (it only 'exists' in the other custom scripts where I set it up as a local variable).

Instead of the 0.01 wait, I'd like to see a timer with 0 expiration time.
~Changed. Will it still nullify the damage?

Thank you for the feedback Maker :) +rep
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
~Changed. Btw, is there any advantage using this over having to destroy and re-create the text?

My understanding is that it's better to use the same text so that no new objects are created constantly in memory.


Again, is there any benefit or does it make no difference? I've seen many other systems use this.

Non array variables are faster, and reserve less memory.

Lol, sorry I'm not good with hashtables. The loop doesn't do much anyways, it is basically just resetting a few real variables and moving floating text.

You're looping through all units to find the correct unit.

Let's say you have 80 units in the map that have the shield, and that the GDD_DamageUnit is stored to ES_Unit[80]. In that case there would be 80 checks, which is not good. On average one would have to do maxIndex/2 checks, 40 in this case.

If the values were saved to a hashtable, then you could just get the handle id of the unit and directly load the data assigned to that id.

Mind showing me please? I only used Custom Script there because 'temp_unit' is not an 'existing' variable (it only 'exists' in the other custom scripts where I set it up as a local variable).

Custom script: call UnitRemoveAbility(temp_unit, 'A000' )

I just noticed that you should null the unit at the very end of the trigger. Now it's not nulled if the mana condition is not met.

~Changed. Will it still nullify the damage?

Yes it should since even a timer with 0 expirating isn't instant. Thus the ability is removed after a delay, and HP is reset.

Thank you for the feedback Maker :)

You're welcome :)
 
Thank you for the feedback Maker :) *+rep
You're welcome :)
*There I've fixed it up for ya!

K, now that you've explained to me, I will fix those things up with the exception of the Hashtable implementation (lolz I don't know how).

Thanks again.

Is there no one else who wishes to comment?
 
Level 11
Joined
Sep 12, 2008
Messages
657
Hmm.. how about add GetLocalPlayer or so on, to find any player which can see the shielded unit, to show/hide the texttag for, since right now its a very bad tactical spell, since any player in the game sees you from all the map.
 
Level 11
Joined
Sep 12, 2008
Messages
657
nah, check fog.
JASS:
native IsFogEnabled takes nothing returns boolean
constant native IsFoggedToPlayer takes real x, real y, player whichPlayer returns boolean
constant native IsLocationFoggedToPlayer takes location whichLocation, player whichPlayer returns boolean
constant native IsUnitFogged takes unit whichUnit, player whichPlayer returns boolean
Hope that helped ^^

Edit:
i just thought of this too:
JASS:
constant native IsUnitHidden takes unit whichUnit returns boolean
 
Status
Not open for further replies.
Top