1. Are you planning to upload your awesome spell or system to Hive? Please review the rules here.
    Dismiss Notice
  2. The poll for our 11th Music Contest is up! Help us choose the most awesome cinematic tracks by casting a vote!
    Dismiss Notice
  3. Melee Mapping contest #3 - Poll is up! Vote for the best 4v4 melee maps!
    Dismiss Notice
  4. The 30th edition of the Modeling Contest is finally up! The Portable Buildings need your attention, so come along and have a blast!
    Dismiss Notice
  5. The Aftermath has been revealed for the 19th Terraining Contest! Be sure to check out the Results and see what came out of it.
    Dismiss Notice

Couter bash 1.3

Submitted by Chaosy
This bundle is marked as approved. It works and satisfies the submission rules.
A spell I made some time ago now reuploaded to hive. it is MUI and should be leak free now.

the spell;
When unit is attacked there is a X chance to knockback the attacker

trigger

  • setup
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- creates a hashtable --------
      • Hashtable - Create a hashtable
      • Set CB_hash = (Last created hashtable)
      • -------- Settings --------
      • -------- Sets how long the unit will be knocked back --------
      • -------- note, index (array) = level of ability --------
      • Set CB_distance_setup[1] = 150.00
      • Set CB_distance_setup[2] = 200.00
      • Set CB_distance_setup[3] = 300.00
      • -------- Sets the chance to knock back a unit in % --------
      • Set CB_chance_to_knockback[1] = 5
      • Set CB_chance_to_knockback[2] = 10
      • Set CB_chance_to_knockback[3] = 20
      • -------- If the unit are knocked back into trees should they be destroied? --------
      • Set CB_BOOOM = True
      • -------- Effects --------
      • Set CB_effectOnCast = Abilities\Spells\Human\Polymorph\PolyMorphDoneGround.mdl
      • Set CB_effectOnLoop = Abilities\Weapons\AncientProtectorMissile\AncientProtectorMissile.mdl

  • cast
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Random integer number between 1 and 100) Less than or equal to CB_chance_to_knockback[(Level of |cffff0000Counter bash|r for (Triggering unit))]
    • Actions
      • Set CB_defender = (Triggering unit)
      • Set CB_attacker = (Attacking unit)
      • Set CB_attacked_loc = (Position of CB_defender)
      • Set CB_attacking_loc = (Position of CB_attacker)
      • Set CB_angle = (Angle from CB_attacked_loc to CB_attacking_loc)
      • Set CB_distance = (CB_distance_setup[(Level of |cffff0000Counter bash|r for CB_defender)] x 0.03)
      • Set CB_time = 1.00
      • Hashtable - Save CB_angle as 1 of (Key (Attacking unit)) in CB_hash
      • Hashtable - Save CB_distance as 2 of (Key (Attacking unit)) in CB_hash
      • Hashtable - Save CB_time as 3 of (Key (Attacking unit)) in CB_hash
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (CB_group is empty) Equal to True
        • Then - Actions
          • Trigger - Turn on loop <gen>
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • CB_BOOOM Equal to True
        • Then - Actions
          • Unit - Turn collision for (Attacking unit) Off
        • Else - Actions
      • Unit Group - Add CB_attacker to CB_group
      • Sound - Play AxeMissile2 <gen> at 100.00% volume, attached to CB_attacker
      • Special Effect - Create a special effect attached to the chest of CB_attacker using CB_effectOnCast
      • Special Effect - Destroy (Last created special effect)
      • Unit - Pause CB_attacker
      • -------- removeing leaks --------
      • Custom script: call RemoveLocation(udg_CB_attacking_loc)
      • Custom script: call RemoveLocation(udg_CB_attacked_loc)

  • loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in CB_group and do (Actions)
        • Loop - Actions
          • Set CB_temp_unit = (Picked unit)
          • -------- loads the time from hashtable --------
          • Set CB_time = (Load 3 of (Key (Picked unit)) from CB_hash)
          • -------- if there is time left the trigger will continue else the unit will be stoped from the knock back --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • CB_time Greater than 0.00
            • Then - Actions
              • -------- loads the angle and distance fromhashtable --------
              • Set CB_angle = (Load 1 of (Key (Picked unit)) from CB_hash)
              • Set CB_distance = (Load 2 of (Key (Picked unit)) from CB_hash)
              • -------- moves the unit a small distance every second makes it looks like hes knocked back --------
              • Set CB_temploc = (Position of (Picked unit))
              • Set CB_temploc_2 = (CB_temploc offset by CB_distance towards CB_angle degrees)
              • Unit - Move CB_temp_unit instantly to CB_temploc_2
              • Special Effect - Create a special effect at CB_temploc_2 using CB_effectOnLoop
              • Special Effect - Destroy (Last created special effect)
              • -------- stores the point of the picked unit --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • CB_BOOOM Equal to True
                • Then - Actions
                  • Destructible - Pick every destructible within 100.00 of CB_temploc_2 and do (Actions)
                    • Loop - Actions
                      • Destructible - Kill (Picked destructible)
                • Else - Actions
              • -------- saves the time left --------
              • Hashtable - Save (CB_time - 0.03) as 3 of (Key (Picked unit)) in CB_hash
              • Custom script: call RemoveLocation(udg_CB_temploc_2)
              • Custom script: call RemoveLocation(udg_CB_temploc)
            • Else - Actions
              • Unit Group - Remove CB_temp_unit from CB_group
              • Unit - Unpause CB_temp_unit
              • Hashtable - Clear all child hashtables of child (Key (Picked unit)) in CB_hash
              • -------- removeing leaks --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • CB_BOOOM Equal to True
                • Then - Actions
                  • Unit - Turn collision for CB_temp_unit On
                • Else - Actions
              • -------- if group is empty the trigger turns off --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (CB_group is empty) Equal to True
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                • Else - Actions



Keywords:
knock, back, spell, knock back, counter, bash
Contents

Counter Bash (Map)

Reviews
Moderator
Approved A basic knockback retaliation spell that could benefit from additional polishing. Suggested changes The knockback speed could diminish over time Instead of pausing the unit, check that the unit is not already in the knockback group...
  1. Reviewed by Maker, Counter bash 1.3, 11th Mar 2012

    Approved

    A basic knockback retaliation spell that could benefit from additional polishing.

    Suggested changes
    • The knockback speed could diminish over time
    • Instead of pausing the unit, check that the unit is not already in the knockback group
      Spells should not really pause units
      You can also try to stun them instead
    • Add the bash chance to the tooltip
    • Disabled version of the icon is missing
    • The research icon should not be the passive version of the icon
    • You could use tree detection system, if BOOM = true it will destroy brisges also for example


    Old reviews


    Reviewed by Maker, Counter bash 1.2, 3rd Mar 2012

    Required changes
    • Disabled icon is missing, passive abilities should have passive version of icons
    • In importing instructions you must mention that the ability used in cast trigger must be configured manually
      For both the condition and the distance
    • You need to flush child hashtable when the spell ends. Hashtable - clear child hashtable of picked unit
    Suggested changes
    • Instead of pausing the unit, check that the unit is not already in the knockback group
    • Add the bash chance to the tooltip
    • You could use tree detection system


    Reviewed by Maker, Counter bash 1.0, 25th Feb 2012

    Required changes
    • Learn tooltip icon is missing
    • In importing instructions you must mention that the ability used in the
      condition in A unit is attacked trigger must be configured manually
    • Set loop initially off
    • Move unit instantly action has a location leak
    • You're setting position of picked unit twice in the looping trigger, set it only once
    • You need to flush child hashtable
    • Units can end up with their collision turned off after the spell is over
    • After moving a unit instantly, the unit can targets nearby enemies. Thus if the bash chance is high, the unit can be caught in a loop. You can push your enemy across the map this way
    Suggested changes
    • Mention the hotkey in tooltip, add the chance to the tooltip
    • Change 0.04 to 0.03. 0.04 is not smooth. The knocback could use diminishing speed to make it look better
    • You could use tree detection system
    • Don't load distance and angle if time < 0
    • Abil level >= 1 condition is not needed, the other condition covers that

     
  2. maddeem

    maddeem

    Joined:
    Jan 1, 2011
    Messages:
    1,209
    Resources:
    5
    Maps:
    2
    Spells:
    3
    Resources:
    5
    you should use
    Code (vJASS):

    call SetUnitX(udg_u,udg_real1)
    call SetUnitY(udg_u,udg_real2)
     

    u being the unit
    Reals are the converted cords of ur point you move the units.
    This would allow many units to be knocked back at the same time with little or no delay.

    OR

    Use a knockback system
    Because atm ur system kills more then trees.
     
  3. Chaosy

    Chaosy

    Joined:
    Jun 9, 2011
    Messages:
    10,430
    Resources:
    17
    Maps:
    1
    Spells:
    10
    Tutorials:
    6
    Resources:
    17
    @maddeem yeah did not think of that i will see what i can do about that

    @maker thanks for all those tips i will fix all i can shortly
     
  4. Magtheridon96

    Magtheridon96

    Joined:
    Dec 12, 2008
    Messages:
    6,004
    Resources:
    26
    Maps:
    1
    Spells:
    8
    Tutorials:
    7
    JASS:
    10
    Resources:
    26
    • -------- THIS ACTION IS NOT NEEDED! --------
    • Hero - Learn skill for Paladin 0002 <gen>: |cffff0000Counter bash|r


    Then put it in a different trigger :p

    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • CB_BOOOM Equal to True
      • Then - Actions
        • Unit - Turn collision for (Picked unit) Off
      • Else - Actions


    I think you mean "On".
     
  5. Chaosy

    Chaosy

    Joined:
    Jun 9, 2011
    Messages:
    10,430
    Resources:
    17
    Maps:
    1
    Spells:
    10
    Tutorials:
    6
    Resources:
    17
    fixed a few things.
    -collision is now on again after the knockback is over
    -learn skill action is in another trigger
    -loop is initally off
    -loop speed is changed to 0.03
    -temploc is only set once in loop trigger
    -removed one condition in the cast trigger
    -added the learn hotkey in the learn desp
    -location leak should be fixed (i think)
    -unit is now paused to avoid attacking during the knock back
    -animation speed reduce removed

    more will be added but its all for now. will edit this post
     
    Last edited: Feb 25, 2012
  6. Magtheridon96

    Magtheridon96

    Joined:
    Dec 12, 2008
    Messages:
    6,004
    Resources:
    26
    Maps:
    1
    Spells:
    8
    Tutorials:
    7
    JASS:
    10
    Resources:
    26
    • Set CB_distance = (CB_distance_setup[(Level of |cffff0000Counter bash|r for CB_defender)] x 0.04)


    You meant 0.03 right? :p

    Also, this leaks:

    • Set CB_temploc = ((Position of (Picked unit)) offset by CB_distance towards CB_angle degrees)


    You need two locations:

    • Set CB_temploc1 = (Position of (Picked unit))
    • Set CB_temploc2 = CB_temploc1 offset by CB_distance towards CB_angle degrees


    Also, instead of constantly repeating that (Picked unit) call, you could store the picked unit into a unit
    variable and use that variable to increase efficiency.

    edit
    You can do the same for Key(Picked unit), Key(Attacking unit), (Attacking unit), etc..
    You can do it for ANYTHING that is used more than once :p
     
  7. Chaosy

    Chaosy

    Joined:
    Jun 9, 2011
    Messages:
    10,430
    Resources:
    17
    Maps:
    1
    Spells:
    10
    Tutorials:
    6
    Resources:
    17
    thanks magtheridon96 i get working at once

    edit done rep+ for your help

    edit 2; the new version 1.3 should be ready for approval now
     
    Last edited: Feb 29, 2012
  8. Chaosy

    Chaosy

    Joined:
    Jun 9, 2011
    Messages:
    10,430
    Resources:
    17
    Maps:
    1
    Spells:
    10
    Tutorials:
    6
    Resources:
    17
    Long overdue update.
    Noticed hive 2.0 fucked up the name of the spell.

    Added some extra configuration
    Added knockback effect
     
  9. yram44

    yram44

    Joined:
    Mar 26, 2011
    Messages:
    38
    Resources:
    0
    Resources:
    0
    Wow 1 of your long time spell. Finally updated I will try it tomorrow!